JAVA COURSE
JAVA COURSE
IF the input values comes int ,string, the system doesn’t consider the string it takes the
blank space for the 2nd string to avoid this we can use:
Eg: string a=sacn.nextline()
Int b = scan.nextint()
To avoid the next string below int we use:
Scan.nextline()
String c=scan.nextline();
FOR LOOP:
It used when we the start and end values
i=1
For(i=1;i<=5;i=i+1);
COUNT:
To count the if or for loop count will use and Count should be in outer of the for loop
Eg: int evencount=0
for(i=1;i<=10;i+1)
{
if(i%2==0)
{
evencount = evencount+1;
}
}
System.out.print(evencount);
ARRAY:
Array is the collection of data’s,its starts from indexing 0,1,2,3
String[] playlist = new String[3]; (for int-- int[] score =new int[5];)
String[]----array ;playlist----variable
Here playlist is the array contains the songs
Playlist[0]=”song1”;
Playlist[2]=”song2”;
System.out.println(playlist[0]);
OR
String playlist[]={“song1”,”song2”}
FOR LOOP WITH 2 values like I and j--if i=3*j=3=9—>9 times loop will run
WHILE LOOP:
It used for infinite values(we don’t know the start and end value)
i=0
while(i<=5)
i=i+1
DO-WHILE LOOP:
It runs atleast once if the condition is fase or true
Eg:
Scanner count=new scanner(system.in)
Int count=0
Count=count.NextInt()
Do
{
System.out.println(enter the number greater than 10);
While(count<10);