The Great Symbian

Anything under the sun goes here!



A. PRIMITIVE DATA TYPES
- Integral Data Types (byte, short, int long)
- Floating Point (float, double)
- Characters (char, string)
- Boolean (true, false)



B. VARIABLES
A variable is an item of data used to store state of objects.

1. Declaring and Initializing Variables
To declare a variable is as follows,
[=initial value];

2. Outputting Variable Data
In order to output the value of a certain variable, we can use the following commands,
System.out.println()
System.out.print()



C. OPERATORS

1 Arithmetic operators
+, *, /, %, -

2 Increment and Decrement operators
++, --

3 Relational operators

Relational operators compare two values and determines the relationship between those
values. The output of evaluation are the boolean values true or false.
>, >=, <, <=, ==, != 4 Logical operators
Logical operators have one or two boolean operands that yield a boolean result. There
are six logical operators: && (logical AND), & (boolean logical AND), (logical OR),
(boolean logical inclusive OR), ^ (boolean logical exclusive OR), and ! (logical NOT).



D. GETTING INPUT FROM THE KEYBOARD

1. Using buffered reader
·Add this at the top of your code:

import java.io.*;

·Add this statement:

BufferedReader dataIn = new BufferedReader(
new InputStreamReader( System.in) );

· Declare a temporary String variable to get the input, and invoke the readLine()
method to get input from the keyboard. You have to type it inside a try-catch block.

try{
String temp = dataIn.readLine();
}
catch( IOException e ){
System.out.println(“Error in getting input”);
}



2. Using JOptionPane

import javax.swing.JOptionPane;
indicates that we want to import the class JOptionPane from the javax.swing package.
We can also write this as,
import javax.swing.*;
The statement,
name = JOptionPane.showInputDialog("Please enter your name");
creates a JOptionPane input dialog, which will display a dialog with a message, a
textfield and an OK button as shown in the figure. This returns a String which we will
save in the name variable.



E. CONTROL STRUCTURES

1. Decision Control Structures
Decision control structures are Java statements that allows us to select and execute
specific blocks of code while skipping other sections.

· if statement
if( boolean_expression )
statement;

· if-else statement
if( boolean_expression )
statement;
else
statement;

· if-else-if statement
if( boolean_expression1 )
statement1;
else if( boolean_expression2 )
statement2;
else
statement3;

· switch statement
switch( switch_expression ){
case case_selector1:
statement1; //
statement2; //block 1
. . .
//
break;
case case_selector2:
statement1; //
statement2; //block 2
. . .
//
break;
. . .
default:
statement1; //
statement2; //block n
. . .
//
break;
}

2. Repetition Control Structures
Repetition control structures are Java statements that allows us to execute specific
blocks of code a number of times. There are three types of repetition control structures,
the while, do-while and for loops.

·while loop

The while statement has the form,
while( boolean_expression ){
statement1;
statement2;
. . .
}

· do-while loop
The do-while statement has the form,
do{
statement1;
statement2;
. . .
}while( boolean_expression );


· for loop
The for loop has the form,
for (InitializationExpression; LoopCondition; StepExpression){
statement1;
statement2;
. . .
}




F. Java Arrays

1. Declaring Arrays

Arrays must be declared like all variables. When declaring an array, you list the data
type, followed by a set of square brackets[], followed by the identifier name. For
example,
int []ages;
or you can place the brackets after the identifier. For example,
int ages[];
After declaring, we must create the array and specify its length with a constructor
statement. This process in Java is called instantiation (the Java word for creates). In
order to instantiate an object, we need to use a constructor for this. We will cover more
about instantiating objects and constructors later. Take note, that the size of an array
cannot be changed once you've initialized it. For example,
//declaration
int ages[];
//instantiate object
ages = new int[100];
or, can also be written as,
//declare and instantiate
object
int ages[] = new
int[100];

2. Accessing an array element
To access an array element, or a part of the array, you use a number called an index or
a subscript.

3. Array length
In order to get the number of elements in an array, you can use the length field of an
array. The length field of an array returns the size of the array. It can be used by writing,
arrayName.length

4. Multidimensional Arrays
Multidimensional arrays are implemented as arrays of arrays. Multidimensional arrays
are declared by appending the appropriate number of bracket pairs after the array name.



G. JAVA APPLETS

· Life cycle of an applet
-init()
-start()
-stop()
-destroy()

· drawing strings
drawString();
· drawing ovals
drawOval();
· drawing polygons
drawPolygon();
· drawing rectangles
drawRect();
· drawing lines
drawLine();
· changing font color, size, type, and styles






I. FILE HANDLING

· Reading inputs from a text file

· Writing outputs in a text file

0 comments:

FEEDS

Add to Google Reader or Homepage