Java programming examples
Example 1: Display message on computer screen.class First { public static void main(String[] arguments) { System.out.println("Let's do something using Java technology."); } }
Output of program:
Example 2: Print integers
class Integers { public static void main(String[] arguments) { int c; //declaring a variable /* Using for loop to repeat instruction execution */ for (c = 1; c <= 10; c++) { System.out.println(c); } } }
If else control instructions:
class Condition { public static void main(String[] args) { boolean learning = true; if (learning) { System.out.println("Java programmer"); } else { System.out.println("What are you doing here?"); } } }
Command line arguments:
class Arguments { public static void main(String[] args) { for (String t: args) { System.out.println(t); } } }
No comments:
Post a Comment