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

JAVA COURSE

This document provides an overview of basic Java programming concepts, including class creation, input/output operations, and control structures like loops and conditionals. It explains the use of the Scanner class for user input, string comparison, logical operators, and the structure of for, while, and do-while loops. Additionally, it covers arrays and their initialization, along with examples of counting even numbers and using ternary operators.

Uploaded by

Priya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

JAVA COURSE

This document provides an overview of basic Java programming concepts, including class creation, input/output operations, and control structures like loops and conditionals. It explains the use of the Scanner class for user input, string comparison, logical operators, and the structure of for, while, and do-while loops. Additionally, it covers arrays and their initialization, along with examples of counting even numbers and using ternary operators.

Uploaded by

Priya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

JAVA COURSE

1st we should create class


 Excutes 1st MAIN functionpublic static void main (string args[])
 System .out.print(“hello world”)--to print the output
 To get input from user---Scanner class used
Eg.Scanner Priya = new scanner(system. in);
Int a =Priya. Nextint();
String b= priya.nextline();-for string
we use nextline()

 To print output with variable:


Name=Priya
System.out.print(“my name is”+name);

 To print the output to the next line


System.out.println(“my nameis”)

 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();

 To check the string are equal or not:


Must have the NEW string keyword .
To check the strings are equal we must use.equal function
EG: f1.equals(f2)
 Logicall operator:
&&-AND
||-OR
 Ternary operator:
Variable=(condition)? ”if true” : ”if false”;
System.out.print(TRUE? “yes”:”no”);
This operator returns anything in result but if clause does’not give false part
without else

 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);

You might also like