Java class add field to class
class Account {//from w ww. ja va 2 s . co m String name; String address; double balance; } public class Main { public static void main(String args[]) { Account myAccount; Account yourAccount; myAccount = new Account(); yourAccount = new Account(); myAccount.name = "Java"; myAccount.address = "222 Main Lane"; myAccount.balance = 24.02; yourAccount.name = "Javascript"; yourAccount.address = "111 Main Street"; yourAccount.balance = 42.42; System.out.print(myAccount.name); System.out.print(" ("); System.out.print(myAccount.address); System.out.print(") has $"); System.out.print(myAccount.balance); System.out.println(); System.out.print(yourAccount.name); System.out.print(" ("); System.out.print(yourAccount.address); System.out.print(") has $"); System.out.print(yourAccount.balance); } }