You are on page 1of 20

chapters

Introduction Basics Instructions Methods & arrays Object oriented programming Ingeritance & modifiers Polymorphism&Abstraction Package & Interface Exeptions handlin & streams GUI SQL Data base

Basics
Variables
Comments Constants

Casting
Operation

Variables

Esc a p e seq uenc e Desc rip tion \n Newline. Position the screen cursor to the beginning of the next line. \t Horizontal tab. Move the screen cursor to the next tab stop. \r Carriage return. Position the screen cursor to the beginning of the current line; do not advance to the next line. Any characters output after the carriage return overwrite the characters previously output on that line. \\ Backslash. Used to print a backslash character. \" Double quote. Used to print a double-quote character. For example, System.out.println( "\"in quotes\"" ); displays "in quotes" Fig. 2.5 Som e c om mon esc a p e seq uenc es.

Casting

)Variable_name=(variable)(data 0=Ex: int result 5.1-5-01=result )5.1-5-01()Result =(int

Constants
Define in C++ b ut in java called final Ex: Final float pi =3.14 Comments 1. One line //comment 2. More than one line /* comment */

Chapter 2 Instructions
I/P & O/P instructions use dialouge box

Looping Control Statements Conditional operators Switch

o/p instruction using dialouge box


JOptionPane.showMessageDialog( null, message that appear" );
We should use swing library Import javax.swing.JOptonPane;

o/p instruction using dialouge box


Another method JOptionPane.ShowDialog(null,the sum is+ sum

,results,JoptionPane.PLAIN_MESSAGE) To appear a variable we put pefore it +.


Second: string to display Third: string in title bar Fourth: type of message dialog with icon

Message dialog type JOptionPane.ERROR_MESSAGE

Icon

Description Displays a dialog that indicates an error to the user. Displays a dialog with an informational message to the user. The user can simply dismiss the dialog. Displays a dialog that warns the user of a potential problem. Displays a dialog that poses a question to the user. This dialog normally requires a response, such as clicking on a Yes or a No button.

JOptionPane.INFORMATION_MESSAGE

JOptionPane.WARNING_MESSAGE JOptionPane.QUESTION_MESSAGE

Displays a dialog that simply contains a message, with no icon. Fig. 2.12 JOptionPane constants for message dialogs.

JOptionPane.PLAIN_MESSAGE

no icon

Input
Variable=JOptionPane.showInputDialog( "Enter "

); Ex: String Number; Int number; Number =JOptionPane.showInputDialog( "Enter integer" ); number = Integer.parseInt( firstNumber ); int

Looping
For
While Dowhile

Control statements
If
If.else If.elseif.endif.

Switchcase..

4 Chapter methods & arrays


Ex Int function (int n) take int & return int

methods
Ex

Public class Method{ Public int sum(int a,intb) {int s; S=a+b; Return s; } Public static void main(String[] args) {int r; Metod Obj=new Method // defination for class will discussed later r=Obj.Sum(10,15); System.out.prtln(the sum is +r) // instruction for o/p }}

Array
Definition

ex : int sum = new int [4] // 4 is size or int []sum={1,4,5,7} or int [] sum;sum=new int[4]; for

You might also like