0% found this document useful (0 votes)
0 views

Module 2 Core Java Fundamentals

Uploaded by

Jolly Thomas
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Module 2 Core Java Fundamentals

Uploaded by

Jolly Thomas
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Module 2 Core Java

Fundamentals
Primitive data types-integers,
floating point types , characters,
Boolean
• Data types are divided into two
groups:

primitive data type: includes int,


long, short, byte, char, and
Boolean.

Non-primitive data types include


arrays, classes, and strings.
Integer types
• Integer types store whole numbers, positive or negative (such as 123
or -456) without decimals.
Floating point types
• You should use a floating point type whenever you need a number
with a decimal , such as 9.99 or 3.1415.
• The float datatypes can store fractional numbers.
• Note that you should end the value with an “f” for floats.
public class Main{
Public static void main(String[] args ){
float myNum=5.75f;
System.out.println(myNum);
}
}
Boolean types

• A data type that can only one or two values , like:


• YES/NO
• ON/OFF
• TRUE/FALSE
• For this , Java has a Boolean data type , which can only take the values
true/false.
Characters
• The char data type is used to store a single character. The character
must be surrounded by single quotes, like ‘a’ or ’C’.
public class Main{
Public static void main(String[] args )
char myGrade = ‘B’ ;
System.out.println(myGrade);
}
}
Strings
• The String data type stores a sequence of characters(text).
• String values must be surrounded by double quotes.
public class Main{
public static void main(String[] args){
String greeting = “Hello World”;
System.out.println(greeting);
}
}

You might also like