SlideShare a Scribd company logo
1 of 1
Download to read offline
Java programming cheat sheet
Data Type Conversion
Narrowing
Widening
Casting
promotion
Assignment
The desired types
are placed inside ()
int y=(int)1.5;
Binary operation
involving two operands
of different types
double y=2 +1.5;
One type to
another type
int x=2;
double y=x;
Console input: Use Scanner Class
Console output
1-import declaration
import java.util.Scanner;
2-Scanner object with data source
Scanner input=new Scanner (System.in);
3-Scanner methods:
DataTypenameVariable=ObjectScanner.nextDataType();
String s=input.next(); //read a word | String s=input.nextLine(); //read a line
char c=input.next().charAt(0);
"+0);
ends a line of output
("
.println
System.out
"+0);
doesn't ends a line of output
("
.print
System.out
(+) used to connect more than one item
System.out.printf("format String", variable list);
5.147300
System.out.printf("%f%n", 5.1473); //output:
Control flow statement
switch - case
Nested if
Ternary operator
? :
if-else
if
Selection (Decision):
Choose between two
or more possible
action based on some
condition.
switch(expression){
case x:
// code block
break;
default:
// code block }
if(condition1){
//Executes when
the condition1 is true
}
if(condition2){
Executes
when the condition2 is
true}
It's shorthand of
if-else
condition?True:False
if (condition) {
//code executed if
the condition is
true}
else {
// code executed if
the condition is
false}
if (condition)
{
// block of code to be executed if the condition is
true
}
Nested loop
do-while: post test
while: pre test
for: pre test
Repetition(iteration):
Repeats a group of
actions until a
stopping condition
occurs.
for(initial action ;condition;
action after each loop){
for(initial action ;condition;
action after each loop){
//statement of inner }
// statement of outer}
Control variable = initial
value;
do{ //statement
Update controlvariable; }
while (condition)
Control variable = initial value;
while (condition){
//statement
Update control variable;
}
for(initial action;condition; action after each loop)
{
//statement
}
return: using in body of methods
continue
break
Branching(jump):
Interrupts the flow of
actions.
Return Type methods
Void
Labeled continue
Skips the current
iteration of the
inner most (for,
while, do-
while)loop
Labeled break
Terminate the inner
most(Switch,for,while,
do-while)statement
Require one or more return
statement
Method header (parameters){
method body
return expression ;}
Doesn't require a return
statement
loop:
for(int i=0;i<2;i++){
for(int j=0;j<5;j++)
if(j==2)
continue loop;}
loop:
for(int i=0;i<2;i++){
for(int j=0;j<5;j++)
if(j==2)
break loop;}
.
is a value that cannot be changed after assigning it
Constant:
= value;
identifier_name
datatype
final
Syntax:
=3.14;
PI
double
final
For ex:
Methods of Array
Methods of Math
Methods of String
Methods
import java.util.Arrays;
int a=Arrays.copyOfRange(a,0,2);
Arrays.sort(a);
boolean b=Arrays.equals(a,newA);
int x=Arrays.binarysearch(a,2);
Math.pow(a,b); //a^b
Math.abs( x );
Math.min( a, b );
Math.max( a, b );
Math.round( x );
Math.ceil( x );
Math.floor( x );
Math.sqrt( x );
a+(int)Math.random( )*b;
//return a random numbers
between a and a+b exclusive
//compare address
boolean b= s1==s2;
//compare value
String s=s1.equals(s2);
String s=s1.equalsIgnoreCase(s2);
String s=s1.toupperCase();
String s=s1.tolowerCase();
String s=s1.trim();
String s=s1.subString(start value);
Char c=s1.charAt(0);
int l=s1.length();
int l=s1.indexOf("String");
int l=s1.compareTo("String");
int l=s1.compareToIgnoreCase();
public int max (int x ,int y)
{
If(x<y)
return x;
else
return y;
}
Operator:
1.Parenthaces
2.Unary:
++
--
+
-
!
Cast
3.Arithametic
:
*
/
%
+
-
4.Compretion
:
<
<=
>
>=
==
!=
5.logical
&
^
|
&&
||
6.Ternary:
? :
7.Assginment:
=
+=
-=
*=
/=
%=
comments in java: // single line , /* multiline */, /** Javadoc*/
Global variable
(instance variable)
Local variable
it's defined within the
class but not inside the
body of any method.
it's accessible to all
methods of the class
Declare in the
body of the
method, can be
used only in the
method
Public class test{
int a;
Public void main(){
int b; }}
Array
Two dimensions
One dimension
datatype [][] arrName = new datatype [R_siza][C_size];
datatype [] arrName = new datatype [];
Syntax
int [][] a= new int [][]{{1,2},{3,4},{5,6}};
int[]a=new int[]{1,2};
Declaration,
creation,
initializing
Col| a[0].length ? 2
Rows| a.length; ? 3
a.length; ? 2
Length
for (int i=0; i<a.length; i++) {
for (int j=0; j<a.length; j++) {
System.out.println(aa[i][j]+""); }
System.out.println();
}
for (int i = 0; i < arr.length; i++){
System.out.println(arr[i] + " ");
} // printing array element
print
Main Data Type
Reverence
primitive
1-classes
2-Arrays
3-String
Non numeric
numeric
1-char
(16 bit)
2-boolean
(true/false)
Integers:
1- byte(8bit)
2-short(16bit)
3-int(32bit)
4-long(64bit)
Floating point:
1-float(32bit)
2-double(64bit)
Body of the method
Parameter list
Method name
Return type
modifier

More Related Content

Similar to java programming cheatsheet

Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressionsLogan Chien
ย 
JAVA Question : Programming Assignment
JAVA Question : Programming AssignmentJAVA Question : Programming Assignment
JAVA Question : Programming AssignmentCoding Assignment Help
ย 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
ย 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notesGOKULKANNANMMECLECTC
ย 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lecturesMSohaib24
ย 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programsSoumya Behera
ย 
Programs of java
Programs of javaPrograms of java
Programs of javashafiq sangi
ย 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
ย 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdfactocomputer
ย 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...MaruMengesha
ย 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfShashikantSathe3
ย 
Chapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).pptChapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).ppthenokmetaferia1
ย 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2YOGESH SINGH
ย 
1 OverviewFor this lab, you will implement the insert method and t.pdf
1 OverviewFor this lab, you will implement the insert method and t.pdf1 OverviewFor this lab, you will implement the insert method and t.pdf
1 OverviewFor this lab, you will implement the insert method and t.pdfrajeshjain2109
ย 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedPascal-Louis Perez
ย 
Import java
Import javaImport java
Import javaheni2121
ย 

Similar to java programming cheatsheet (20)

Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressions
ย 
JAVA Question : Programming Assignment
JAVA Question : Programming AssignmentJAVA Question : Programming Assignment
JAVA Question : Programming Assignment
ย 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
ย 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
ย 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
ย 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
ย 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
ย 
Programs of java
Programs of javaPrograms of java
Programs of java
ย 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
ย 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdf
ย 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
ย 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
ย 
Unit 4 (1)
Unit 4 (1)Unit 4 (1)
Unit 4 (1)
ย 
Array Cont
Array ContArray Cont
Array Cont
ย 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
ย 
Chapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).pptChapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).ppt
ย 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
ย 
1 OverviewFor this lab, you will implement the insert method and t.pdf
1 OverviewFor this lab, you will implement the insert method and t.pdf1 OverviewFor this lab, you will implement the insert method and t.pdf
1 OverviewFor this lab, you will implement the insert method and t.pdf
ย 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing Speed
ย 
Import java
Import javaImport java
Import java
ย 

Recently uploaded

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
ย 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
ย 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
ย 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
ย 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
ย 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
ย 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
ย 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
ย 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
ย 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
ย 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
ย 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
ย 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
ย 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
ย 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
ย 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
ย 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
ย 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
ย 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
ย 

Recently uploaded (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
ย 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
ย 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
ย 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
ย 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
ย 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
ย 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
ย 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
ย 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
ย 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
ย 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
ย 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
ย 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
ย 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
ย 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
ย 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
ย 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
ย 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
ย 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
ย 

java programming cheatsheet

  • 1. Java programming cheat sheet Data Type Conversion Narrowing Widening Casting promotion Assignment The desired types are placed inside () int y=(int)1.5; Binary operation involving two operands of different types double y=2 +1.5; One type to another type int x=2; double y=x; Console input: Use Scanner Class Console output 1-import declaration import java.util.Scanner; 2-Scanner object with data source Scanner input=new Scanner (System.in); 3-Scanner methods: DataTypenameVariable=ObjectScanner.nextDataType(); String s=input.next(); //read a word | String s=input.nextLine(); //read a line char c=input.next().charAt(0); "+0); ends a line of output (" .println System.out "+0); doesn't ends a line of output (" .print System.out (+) used to connect more than one item System.out.printf("format String", variable list); 5.147300 System.out.printf("%f%n", 5.1473); //output: Control flow statement switch - case Nested if Ternary operator ? : if-else if Selection (Decision): Choose between two or more possible action based on some condition. switch(expression){ case x: // code block break; default: // code block } if(condition1){ //Executes when the condition1 is true } if(condition2){ Executes when the condition2 is true} It's shorthand of if-else condition?True:False if (condition) { //code executed if the condition is true} else { // code executed if the condition is false} if (condition) { // block of code to be executed if the condition is true } Nested loop do-while: post test while: pre test for: pre test Repetition(iteration): Repeats a group of actions until a stopping condition occurs. for(initial action ;condition; action after each loop){ for(initial action ;condition; action after each loop){ //statement of inner } // statement of outer} Control variable = initial value; do{ //statement Update controlvariable; } while (condition) Control variable = initial value; while (condition){ //statement Update control variable; } for(initial action;condition; action after each loop) { //statement } return: using in body of methods continue break Branching(jump): Interrupts the flow of actions. Return Type methods Void Labeled continue Skips the current iteration of the inner most (for, while, do- while)loop Labeled break Terminate the inner most(Switch,for,while, do-while)statement Require one or more return statement Method header (parameters){ method body return expression ;} Doesn't require a return statement loop: for(int i=0;i<2;i++){ for(int j=0;j<5;j++) if(j==2) continue loop;} loop: for(int i=0;i<2;i++){ for(int j=0;j<5;j++) if(j==2) break loop;} . is a value that cannot be changed after assigning it Constant: = value; identifier_name datatype final Syntax: =3.14; PI double final For ex: Methods of Array Methods of Math Methods of String Methods import java.util.Arrays; int a=Arrays.copyOfRange(a,0,2); Arrays.sort(a); boolean b=Arrays.equals(a,newA); int x=Arrays.binarysearch(a,2); Math.pow(a,b); //a^b Math.abs( x ); Math.min( a, b ); Math.max( a, b ); Math.round( x ); Math.ceil( x ); Math.floor( x ); Math.sqrt( x ); a+(int)Math.random( )*b; //return a random numbers between a and a+b exclusive //compare address boolean b= s1==s2; //compare value String s=s1.equals(s2); String s=s1.equalsIgnoreCase(s2); String s=s1.toupperCase(); String s=s1.tolowerCase(); String s=s1.trim(); String s=s1.subString(start value); Char c=s1.charAt(0); int l=s1.length(); int l=s1.indexOf("String"); int l=s1.compareTo("String"); int l=s1.compareToIgnoreCase(); public int max (int x ,int y) { If(x<y) return x; else return y; } Operator: 1.Parenthaces 2.Unary: ++ -- + - ! Cast 3.Arithametic : * / % + - 4.Compretion : < <= > >= == != 5.logical & ^ | && || 6.Ternary: ? : 7.Assginment: = += -= *= /= %= comments in java: // single line , /* multiline */, /** Javadoc*/ Global variable (instance variable) Local variable it's defined within the class but not inside the body of any method. it's accessible to all methods of the class Declare in the body of the method, can be used only in the method Public class test{ int a; Public void main(){ int b; }} Array Two dimensions One dimension datatype [][] arrName = new datatype [R_siza][C_size]; datatype [] arrName = new datatype []; Syntax int [][] a= new int [][]{{1,2},{3,4},{5,6}}; int[]a=new int[]{1,2}; Declaration, creation, initializing Col| a[0].length ? 2 Rows| a.length; ? 3 a.length; ? 2 Length for (int i=0; i<a.length; i++) { for (int j=0; j<a.length; j++) { System.out.println(aa[i][j]+""); } System.out.println(); } for (int i = 0; i < arr.length; i++){ System.out.println(arr[i] + " "); } // printing array element print Main Data Type Reverence primitive 1-classes 2-Arrays 3-String Non numeric numeric 1-char (16 bit) 2-boolean (true/false) Integers: 1- byte(8bit) 2-short(16bit) 3-int(32bit) 4-long(64bit) Floating point: 1-float(32bit) 2-double(64bit) Body of the method Parameter list Method name Return type modifier