practice java programs code example
Example 1: basic java coding
public class AddTwoNumbers {
public static void main(String[] args) {
int num1 = 5, num2 = 15, sum;
sum = num1 + num2;
System.out.println("Sum of these numbers: "+sum);
}
}
Example 2: java coding practice
package com.example.packagenames.are.reverse.domain.all.lowercase.seperated.by.dots;
public class TypeNamesArePascalCase(){
public static final String CONSTANTS_ARE_UPPER_CASE_WITH_UNDERSCORES="Hello World";
private int membersArePrivateAndCamelCase;
public int getMembersArePrivateAndCamelCase(){
return membersArePrivateAndCamelCase;
}
public void setMembersArePrivateAndCamelCase(int membersArePrivateAndCamelCase){
this.membersArePrivateAndCamelCase=membersArePrivateAndCamelCase;
}
public void methodsAreCamelCase(){
}
}
public enum EnumsAreTypes{
ENUM_CONSTANTS,ARE,CONSTANTS
}