Example of Java Programming

Java Programming Output Example

 SAVING A JAVA PROGRAM
 title of the program.java (ex. Hello.java)
CMD CODES OPENING A JAVA PROGRAM

1. CD C:\
2. CD JAVA
3. CD JDK*
4. CD BIN
5. JAVAC title of the program
6. JAVA title of the program

codes.: println - next line
            print - space
            printf - computation

TRY THIS

Open a notepad and type.:
public class Hello
{
public Static void main(String[]args)
{
System.out.println("Hello World");
}
}

---------------------------------------------------------------------------------------------------------------

Ex2.

TRY THIS

public class A simple java program
{
public static void main(String[]args)
{
System.out.println("My first java program");
System.out.println("The sum of 2 and ="+5);
Stem.out.println("7+8="+(7+8));
}
}

---------------------------------------------------------------------------------------------------------------

TRY THIS
JAVA IMPORT

import java.util.*;
public class Sum
{
static scanner console = new Scanner(System.in)
public static void main(String[]args)
{
int sum a,b;
System.out.println("Enter the first number");
a=console.nextInt();
System.out.println("Enter the second number");
b=console.nextInt();
sum=a+b;
System.out.println("The sum of "+a+b"and"+b+"="+sum);
}
}


0 (mga) komento: