String class is defined in java.lang.String.
It represents character strings (or array of character).
Like any other java class String can be initiated using following syntax:
Class_name identifier = new Class_name(para);
For example, String name = new String("JAVA");
However, as String is commonly used class, it can be initiated as a data type (like int, char),
For example, String name = "JAVA";
Sunday, February 3, 2008
JAVA Data Types
There are 8 primitive Data Types in java.
# Data_Type Size Range
1. byte 8-bit 0 to 127
2. short 16-bit -32,768 to +32,767
3. int 32-bit -2,147,483,648 to +2,147,483,647
4. long 64-bit -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
5. float 32-bit beyond the scope (click here for more information)
6. double 64-bit beyond the scope (click here for more information)
7. boolean Either true true and false
or false
8. char 16-bit '\u0000' (or 0) to '\uffff' (or 65,535).
For more information click here.
# Data_Type Size Range
1. byte 8-bit 0 to 127
2. short 16-bit -32,768 to +32,767
3. int 32-bit -2,147,483,648 to +2,147,483,647
4. long 64-bit -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
5. float 32-bit beyond the scope (click here for more information)
6. double 64-bit beyond the scope (click here for more information)
7. boolean Either true true and false
or false
8. char 16-bit '\u0000' (or 0) to '\uffff' (or 65,535).
For more information click here.
JAVA Lesson 2
Variable declaration:
Syntax : variable_data_type identifier;
Example : int number;
String name;
Variable initialization:
Syntax : identifier = value;
Example : number = 5;
name = "your_name";
Declaring and initializing at the same line
Syntax : variable_data_type identifier = value;
Example : int number = 5;
String name = "your_name";
Syntax : variable_data_type identifier;
Example : int number;
String name;
Variable initialization:
Syntax : identifier = value;
Example : number = 5;
name = "your_name";
Declaring and initializing at the same line
Syntax : variable_data_type identifier = value;
Example : int number = 5;
String name = "your_name";
Saturday, February 2, 2008
JAVA Lesson 1
//Hello World
public class MyFirstJavaProgram{
public static void main(String args[]){
String msg = "Hello World!";
System.out.println(msg);
}
}
//this code will print "Hello World!"
public class MyFirstJavaProgram{
public static void main(String args[]){
String msg = "Hello World!";
System.out.println(msg);
}
}
//this code will print "Hello World!"
Subscribe to:
Comments (Atom)