Java Week 1

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 13

-:

-1 ) (Digits 9, ......... 4 , 3 ,2 ,1 ,0
z ..a -2 ((Letters Z .. A
3- ) ( Special Symbol ) ( ) ) ( : )) ( $
.


) -:
)1 The Character Type
) )
) ( 16 -32767 .32767
A $ c 3
)The String Type 2
) ) )
( ) .

4 + 3 equal 7 3 + 2 =5 This is java program
(3 The Integer Type

) ( - .
0 2 567 -1001
-:
long compiler ) 64
int 32
short ) 16
byte 8

The Float Type (4


) ) ( .
) ( - .
-:
- double 64 1.7E-308 1.7E+308
38.57E-1 67.8E-2
- float 32 3.4E-038 3.4E+038
3.23 4.05- 45.67
(5 The Boolean Type

) (true ) (false 8
x = 3 y = 5 -:
( ) true X< y

)(identifiers

:- )
1- ) (_) (under score).
-2 ) )
)_( ) .
-3 ) _ (.
-4 )
( VALUE value.
5- .
Reserved Words
) (class
) (method ) (compiler -:
abstract const final this for float interface throw true if else char

Comments
) )
) (//
) (*/ )* (/ .

This is First program File_1.java //


to calculate the average of student grades//
)
*This is First program File_1.java/
*/ to calculate the average of student grades
Variable Declaration

.
-:
,..;Type Identifier_1, Identifier_2
Type .
.,Identifier_1, Identifier_2
-:
;..;Type Identifier_1 = Initial_value_1; Type Identifier_2= Initial_value_2

Integer variables
).(int

x,y,z )(integer ;int x, y, z


;short A,B A,B ) (short
).(int
) ;long Item_Number
(int).
Float Variables
).(float
;float a, b, c
; a = 3.5f; b = 5.9f
; c = a+ b
-:
a = 3.5
b = 5.9
c= 9.4
Double variables
) (double -:
; double a, b, c
;a= 5.5555555
;b = 6.6666666
;c = a + b
a=5.55555555
b=6.6666666
c=12.2222221
Character Variables
) ) (char
.

ch1, ch2 65 ch1


) (A ASCII ch2 .B
;char ch1 = 65
;char ch2 = B
String Variables
) (String .S


; String str = Hi This is Frist Program


)
. )
class identifier_name
{
;Variable_Declarations
;statement_1
;statement_2
;statement_3
. Program Body
.
;statement_n
}
class identifier_name
Variable_Declarations
Statement ) );

// This is the first program in java
class Example_one
{
)(// This program starts with a call to main
)public static void main(String [] args
{
// Output Statement
;)System.out.println( Hello ! Welcome to the First JAVA program
}
}
Print Statement

) (print -:
) ;System.out.print(Expr1 + Expr2+
System ( )Package
Expr1+ Expr2
. ) (+
:-
;)System.out.print( ansr + 20 + 30
) (+ ansr
20 30 -:
ansr 2030
:
;))System.out.print( ansr + (20 + 30
:- )
ansr50
:
;)System.out.print(The product of + 8 + * + 3
;)System.out.print(equal to + 24

The product of 8 *3 equal to 24
Escape Characters
)
)\( ) ( :


\ddd )(ddd
\uxxxx )(xxxx
\n
\t 7
\b
\f
\\ \
\
\
Read Statement

) (read )(readLine
.
-:
;)( var = type.valueOf(inData.readLine().trim()).typeValue

var : .
. type
)( ()String valueOf
) (Intrger ).(Float
( .)Buffer trim

) (InputStream
;*.import java.io
));BufferedReader inData=new BufferedReader(new InputStreamReader(System.in
.*; import java.io
class read_int_float
}
public static void main(String[]args) throws IOException
}
; BufferedReader inData=new BufferedReader(new InputStreamReader(System.in))
;int k
;char ch; float x
;System.out.print( Enter your Integer Number)
k=Integer.valueOf(inData.readLine().trim()).intValue();
;System.out.print( Enter your Float Number)
x=Float.valueOf(inData.readLine().trim()).floatValue();
System.out.print( Enter your Character );
ch= (char) inData.read();
System.out.print( Your Integer Number + k);
System.out.print( Your Float Number + x);
System.out.print( Your Character + ch);
}
}

You might also like