Wednesday, April 8, 2015
Example 1
// This application program prints Welcome to Java!
public class Welcome {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}
//--------------
public class WelcomeWithThreeMessages {
public static void main(String[] args) {
System.out.println("Programming is fun!");
System.out.println("Fundamentals First");
System.out.println("Problem Driven");
}
}
//--------------------
public class ComputeExpression {
public static void main(String[] args) {
System.out.println((10.5 + 2 * 3) / (45 - 3.5));
}
}
//--------------
public class ShowSyntaxErrors {
public static main(String[] args) {
System.out.println("Welcome to Java);
}
}
//-----------
// ShowRuntimeErrors.java: Program contains runtime errors
public class ShowRuntimeErrors {
public static void main(String[] args) {
System.out.println(1 / 0);
}
}
//--------------
public class ShowLogicErrors {
public static void main(String[] args) {
System.out.println("Celsius 35 is Fahrenheit degree ");
System.out.println((9 / 5) * 35 + 32);
}
}
//-------------------
Labels:
Code Example
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment