Thursday, 22 May 2014

Java Tutorial 1

0 comments
Q. How to create a new Project ?
A -  Open eclipse -> File -> New -> java Project


Inside java everything is Object.
Public ; - This tells java that this part is available to everyone.
static : Without creating an instance we are calling the main method.
main - This method always execute first.
void :  This method nothing after the execution

public class HelloWorld
{
  static String randomString = "String to print";
  static final double PINUM = 3.141234;
  public static void main(String[] args)
  {
     System.out.println("Hello World");
     System.out.println(randomString);
     System.out.println(PINUM);

     int integerOne=22;
     int intgerTwo = intgerOne +1;
     System.out.println(integerTwo);

   }
}

Primitive data Type in java :-
----------------------------------
byte bigByte =127;
short bigShort = 32767;
int bigInt = 21000000000;
long bigLong=92200000000000000000L;
float bigFloat = 3.14F;
double bigDouble = 3.11111111111111111111111111111111111111111111111;
boolean trueFalse = true;
char randomChar = 65;  //value A
char anotherChar = 'A';  //value A
char escapeChars = '\\';  // all back space char

String A = "Start"
String B = "Last"

String F = A + ' ' + B;

String byteString = Byte.toString(bigBytes);
String shortString = Short.toString(bigBytes);
String intString = Integer.toString(bigBytes);
String longString = Byte.toString(bigBytes);
String floatString = Byte.toString(bigBytes);
String doubleString = Byte.toString(bigBytes);
String booleanString = Byte.toString(bigBytes);

double a Doublevalue = 3.1423333333333;
int doubleToInt = (int) DoubleValue ;  //data loss

int stringToInt = Integer.parseInt(intString);  //

parseShort , parseLong, PasreByte, parseFloat, parseDouble, parseboolean



System.out.println(Float.MAX_VALUE);
System.out.println(Double.MAX_VALUE);
 
© 2013 JAVA | Designed by Making Different | Provided by All Tech Buzz | Powered by Blogger