import java.net.*; //for networking
import java.io.*; //for input/output operations
import java.util.Scanner; // for taking user input
Thursday, 28 July 2011
Control Structures in java
for Repetition Statement
The while statement can be used to implement any counter-controlled loop. Java also provides the for repetition statement, which specifies the counter-controlled-repetition details in a single line of code.
1 //for loop 2 //Counter-controlled repetition statement. 3 4 public class ForCounter 5 { 6 public static void main( String args[] ) 7 { 8 // for statement header includes initialization, 9 // loop-continuation condition and increment 10 for ( int counter = 1; counter <= 10; counter++ ) 11 System.out.printf( "%d ", counter ); 12 13 System.out.println(); // output a newline 14 } // end main 15 } // end class ForCounter
How to be a certified programmer
Java Certification FAQ
Frequently asked Questions on Java Programmer Certification
1.1) What Java Certifications exist?
1.2) What are the benefit of becoming certified and how much more will I get paid?1.3) What happens when new versions of the exam come out
1.4) Is the rumor about certification true?
ADDING TWO NUMBERS WITH USER INPUT
// Addition program that displays the sum of two numbers. import java.util.Scanner; // program uses class Scanner public class Addition { // main method begins execution of Java application public static void main( String args[] ) { // create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
int number1; // first number to add
int number2; // second number to add
int sum; // sum of number1 and number2 System.out.print( "Enter first integer: " ); // prompt number1 = input.nextInt(); // read first number from user
System.out.print( "Enter second integer: " ); // prompt
number2 = input.nextInt(); // read second number from user
sum = number1 + number2; // add numbers
System.out.printf( "Sum is %d\n", sum ); // display sum
} // end method main
} // end class Addition
Introduction to Java
First Program in Java: Printing a Line of Text
// Text-printing program.
// Text-printing program.
public class Welcome1 { // main method begins execution of Java application public static void main( String args[] ) {
System.out.println( "Welcome to Java Programming!" );
} // end method main
} // end class Welcome1
Subscribe to:
Posts (Atom)