「Java」forEachメソッドを利用するサンプル

サンプルコード

List<User>cft = new ArrayList<User>();
        cft.add(new User("yamada", 250000,"tokyo"));
        cft.add(new User("oosaki", 260000."beijing"));
        cft.add(new User("sugimura", 200000,"oosaka"));

       cft.forEach( s -> {
            System.out.println(s.getName());
            System.out.println(s.getSalary());
            System.out.println(s.getAddress());
        });

 

Java

Posted by arkgame