Wednesday, October 28, 2009

Data types of Java

Java has 8 Primitive data types

A. Integer Types (All signed)

1. byte 8 bit
2. short 16 bit
3. int 32 bit
4. long 64 bit

B. Floating Point Types (All signed)

5. float 32 bit
6. double 64 bit

C. Boolean Type

7. boolean true / false

D. Char Type (unsigned)

8. char 16bit









Literal

Literal is a primitive typed values that appears directly inside a program.

int i = 20;
long l = 1000000;
double d = 5.0;

Floating point literals (float & double) are written with a decimal point. By default, a floating-point literal is treated as a double type.

class test
{
public static void main (String args[])
{
float i = 9.8;

}
}

Result of compilation:

G:\work>javac test.java
test.java:5: possible loss of precision
found : double
required: float
float i = 9.8;

class test
{
public static void main (String args[])
{
float i = 9.8F; // F or f

}
}


OK to compile

class test
{
public static void main (String args[])
{
int i = 2200;
int hex = 0x2200; // Starts with 0x
int oct = 02200; // Starts with 0, Binary literal not
// possible
long l = 1000000L;
boolean done = true;
char cr = 'A';
String str = "Abc";

if ( hex > 0x2200 ) { // Do something }

if (done) { // Do something }

if ( cr == 'B') { // Do something }
}
}

Monday, August 17, 2009

Java

Keywords

 

Keywords are language specific and cannot be used for any other purpose other than they are intended for.

 

Example of Java keywords: class, int, public, static, void etc.

 

 

Identifiers

 

Identifiers are used to identify classes, variables, constants etc.

 

Identifiers must start with a letter

 

Class 1 // NOT allowed

{}

 

class One // OK

{}

 

 

Separators

 

()  used to contain lists of parameters in method, surrounding cast

    types, expressions in control statement

{}  defining a block of code for classes, methods etc

[ ] used to declare array types

;   terminating statements

,   separate identifiers, chain statements inside for statement

.   used to indicate a method or variable in a object

 

Sunday, August 9, 2009

Java


Now we can start coding with java. First of all we need a java compiler.  JDK is most uses compiler . JDK (JAVA Development Kit) have a power full compiler and a debugger so any one can find what worng on program is. Just buy it from Market.

Look this Program:

Program1:

class Program1

{

   public static void main(String args[])

   {

                System.out.println(“This is for displaying any variable or string”);

   }

}

It’s a very simple java program.

Here you will find all of your  needed information. Note Java is Object oriented Programming language It also a class based program every program start with class. Write down all code in any text editor(like notepad).

NOTE: Your java program Name must be name of your main class name. That’s mean look the program main class /*where main function*/ it’s class name is program1 so this program name is Program1.java. First letter of class name must be  alphabetic .

now look the picture here every thing will be explain.

 Keyword is special words which do some extra work. Those word Have some extra function and work. Your can use keyword for special purpose. Just mention That you can’t use keyword as statement, variable or any other use. "class” is a key word which explain a Class.



Friday, August 7, 2009

JAVA


Java is most demandable  Programming language for it portability all over the world. From any were and any computer you can access java program. It is a great portability functions. Look this picture. From Bangladesh anyone write Mypro.java then just compile it with javac java compiler. The javac make a Mypro.class file which contain byte code for the program. If any one sends this to any where the people who receive it he can read the program. Program Controls by JVM (java virtual machine)./*We will talk about later.*/  So this Mypro.class is the main file that execute.

Introduction Java-2


Here you see how a c++ and Java Program execute .

Introduction to Java


Java developed by james Gosling at Sum MicroSystem in 1991.

JAVA is a object oriented programming language.

Java Provides both a compiler and a software system called the Java Virtual Machine (JVM).

The Java Development Kit (JDK) is a collection of programs to help developer’s compile, run and debug java program.

Jave is most successful Programming language in the world. Now a days all over the world role by Java. Its Start form our mobile to All Electronic device and also in computer.

Next we will learn about Deferent between java and C++. Till then.