Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Program List for Core Java

Program List for Core Java

Ratings: (0)|Views: 14 |Likes:
Published by lonlyneo

More info:

Published by: lonlyneo on Jun 19, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as ODT, PDF, TXT or read online from Scribd
See more
See less

01/07/2014

pdf

text

original

 
/* This is the first java program :- it prints HelloWorld */package HelloWorld;class HelloWorld{public static void main(String args[]){System.out.println("HelloWorld!");}}/* Command Line arguments*/package HelloWorld;class CommandLineArguments{public static void main(String args[]){System.out.println(" "+args[0]);}}/* simple program with some arithmatic computation*/class Example2{public static void main(String args[]){int num; // this declares a variable called numnum = 100;System.out.println("This is num = "+num);num = num * 2;System.out.print(" The value of num*2 is ");System.out.println(num);}}
 
/* Demonstrations of simple if statement*/class Example3IfSample{public static void main(String args[]){int x, y;x = 10;y = 20;if(x<y){System.out.println("x is less than y");}x = x*2;if(x == y)System.out.println("x is now equal to y");x = x*2;if(x > y)System.out.println("x is now greater than y");// this wont display anythingif(x==y)System.out.println("This will not be displayed...");}}// Demonstrate For Statementclass Example04DemoFor{public static void main(String args[])// String[] args{int x;for(x=0; x<10; x++)System.out.println("This is x : "+x);}}
 
// Demonstrate Block of codeclass Example05BlockCode{public static void main(String args[]){int x, y;y = 20;// the target of this loop is a blockfor(x=0; x<10; x++){System.out.println("This is x : "+x);System.out.println("This is y : "+y);y = y - 2;}}}// Compute distance light travels using long variablesclass Example06DemoLong{public static void main(String args[]){int lightspeed;long days;long seconds;long distance;// approximate speed of light in miles per secondlightspeed = 186000;days = 1000; // specify number of daysseconds = days * 24 * 60 * 60; // convert to secondsdistance = lightspeed * seconds;// compute the distanceSystem.out.print("In "+days);System.out.print(" days light will travel about ");System.out.println(distance + " miles.");

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->