Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

summary of java

Rating
-
Sold
-
Pages
20
Uploaded on
06-12-2024
Written in
2024/2025

### Java Summary (Very Short Notes) - **Platform**: Object-oriented, platform-independent via JVM. - **Key Features**: Simple, secure, portable, robust, multi-threaded. - **Syntax**: Similar to C++, but simpler. - **Main Concepts**: - **Class & Object**: Core of Java. - **Inheritance**: Reuse code via "extends". - **Polymorphism**: Same method, different forms. - **Encapsulation**: Data hiding with private/protected access. - **Abstraction**: Focus on "what" over "how". - **Memory Management**: Automatic Garbage Collection. - **Execution**: `javac` for compilation, `java` for execution. - **API**: Rich libraries (Collections, IO, Networking). Widely used for web, mobile (Android), and enterprise apps.

Show more Read less
Institution
Course

Content preview

Study Notes: Installing Java Development Kit (JDK) and Setting Up the Environment

What is JDK?

JDK (Java Development Kit) is a software development environment used for developing Java
applications and applets. It includes the Java Runtime Environment (JRE), an interpreter/loader
(Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and other tools
needed in Java development.

Installing JDK:

1. Go to the official Oracle website (https://www.oracle.com/java/technologies/javase-jdk15-
downloads.html) and download the latest version of JDK.

2. After downloading, open the installer and follow the instructions to install JDK on your
system.

3. Once installation is complete, verify the installation by opening a command prompt
(Windows) or terminal (Mac/Linux) and typing the following command:

java -version

javac -version

The output should display the version number of Java and javac, indicating that JDK is installed
properly.

Setting Up the Environment:

After installing JDK, the next step is to set up the environment. This involves setting the PATH and
JAVA_HOME variables.

Windows:

1. Right-click on "Computer" or "This PC" and select "Properties."

2. Click on "Advanced system settings" and then click on the "Environment Variables" button.

3. Under "User variables," click on "New" and add a variable named JAVA_HOME with the value
set to the installation path of JDK (e.g., C:\Program Files\Java\jdk-15.0.2).

4. Under "System variables," scroll down and find the PATH variable. Select it and click on
"Edit."

5. Add the following value in the "Variable value" field: %JAVA_HOME%\bin;

6. Click on "OK" to close all windows and save the changes.

Mac/Linux:

1. Open a terminal and open the .bash_profile or .zshrc file using a text editor (e.g., nano
~/.bash_profile).

2. Add the following lines to the file:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home

export PATH=$JAVA_HOME/bin:$PATH

,Replace jdk-15.0.2 with the version number of JDK installed on your system.

3. Save the file and close the text editor.

4. Restart the terminal and verify the environment variables by typing the following command:

echo $JAVA_HOME

echo $PATH

The output should display the installation path of JDK and the bin directory included in the PATH
variable.




Understanding Primitive Data Types in Java

In Java, there are eight primitive data types: byte, short, int, long, float, double, char, and boolean.
These data types are the building blocks of any Java program, and it's essential to understand how
they work.

1. Numeric Data Types

Java has four numeric data types: byte, short, int, and long. These data types represent whole
numbers, and they differ in the range of values they can store.

 byte: A byte data type can store whole numbers from -128 to 127. It uses 8 bits of memory.

 short: A short data type can store whole numbers from -32,768 to 32,767. It uses 16 bits of
memory.

 int: An int data type can store whole numbers from -2,147,483,648 to 2,147,483,647. It uses
32 bits of memory.

 long: A long data type can store whole numbers from -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807. It uses 64 bits of memory.

Here's an example of how to declare and initialize these data types:

byte myByte = 127;

short myShort = 32767;

int myInt = 2147483647;

long myLong = 9223372036854775807L; // Note the 'L' at the end to indicate a long value

2. Floating-Point Data Types

Java has two floating-point data types: float and double. These data types represent fractional
numbers, and they differ in the range of values they can store and the precision of those values.

 float: A float data type can store fractional numbers from 1.4E-45 to 3.4028235E38 with a
precision of 7 decimal places. It uses 32 bits of memory.

,  double: A double data type can store fractional numbers from 4.9E-324 to
1.7976931348623157E308 with a precision of 15 decimal places. It uses 64 bits of memory.

Here's an example of how to declare and initialize these data types:

float myFloat = 3.14159265f; // Note the 'f' at the end to indicate a float value

double myDouble = 2.718281828459045;

3. Character Data Type

Java has one character data type: char. A char data type can store a single character or Unicode
value. It uses 16 bits of memory.

Here's an example of how to declare and initialize a char data type:

char myChar = 'A';

4. Boolean Data Type

Java has one boolean data type: boolean. A boolean data type can store a value that is
either true or false. It uses 1 bit of memory.

Here's an example of how to declare and initialize a boolean data type:

boolean myBoolean = true;

5. Integer Literals

Java supports integer literals in decimal, hexadecimal, and binary formats.

 Decimal: A decimal integer literal is a sequence of digits without a leading zero.

 Hexadecimal: A hexadecimal integer literal starts with a leading '0x' or '0X' followed by one
or more hexadecimal digits (0-9, a-f, A-F).

 Binary: A binary integer literal starts with a leading '0b' or '0B' followed by one or more
binary digits (0, 1).

Here's an example of how to declare and initialize an int data type using decimal, hexadecimal, and
binary literals:

int decimal = 10;

int hexadecimal = 0x10;

int binary = 0b10;

Working with Non-Primitive Data Types in Java

In Java, there are two types of data types: primitive and non-primitive. In this section, we will focus
on non-primitive data types, which are also known as reference types. These include:

 Classes: blueprint for creating objects (e.g. String, Scanner, JFrame)

 Interfaces: defines a set of methods that a class can implement

 Arrays: a collection of elements of the same type

Written for

Course

Document information

Uploaded on
December 6, 2024
Number of pages
20
Written in
2024/2025
Type
SUMMARY

Subjects

$11.79
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
avinashbkkl07

Get to know the seller

Seller avatar
avinashbkkl07 karunya institute of technology and sciences
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions