7 |
import java.util.ArrayList; public class Main { /** * @param args */ public static void main(String[] args) { ArrayList list1 = new ArrayList(); list1.add(1); list1.add(4); list1.add(9); list1.add(16); list1.add(25); ArrayList list2 = new ArrayList(); list2.add(1); list2.add(2); list2.add(4); list2.add(8); list2.add(16); System.out.println(list1.get(3)); System.out.println(list2.get(3)); } } |
public class Main { /** * @param args */ public static void main(String[] args) { Person p1 = new Person(); p1.setHeight(1.8); // p1.height = 1.8; でもよい p1.setWeight(70); // p1.weight = 70; でもよい Person p2 = new Person(); p2.setHeight(1.65); // p2.height = 1.65; でもよい p2.setWeight(60); // p2.weight = 60; でもよい double bmi1 = p1.getBMI(); double bmi2 = p2.getBMI(); System.out.println("1人目のBMI:" + bmi1); System.out.println("2人目のBMI:" + bmi2); } } |
public class Main { /** * @param args */ public static void main(String[] args) { Person p1 = new Person(1.8, 70); Person p2 = new Person(1.65, 60); double bmi1 = p1.getBMI(); double bmi2 = p2.getBMI(); System.out.println("1人目のBMI:" + bmi1); System.out.println("2人目のBMI:" + bmi2); } } |