SHARE
TWEET

Lista

Bwagojche Jun 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.ArrayList;
  2. import java.util.List;
  3. /* so druga klasa napravena Student
  4.  * Gi vnesuvame predmetite i promenlivite i gi zadaduvame vrednostite za promelivite
  5.  * pa ja kreirame listata i so naredbata add dodavame novi objekti za vo listata
  6.  * i so for naredba gi odreduvame od kade do kade da se barat predmetite
  7.  * i na kraj se printat
  8.  *
  9.  * TreeSet e lista a podreduvanje
  10.  * LinkHashSet e lista kako se vneseni taka i gi prezentira i e najbavna
  11.  *
  12.  */
  13. public class AppList {
  14.     public static void main(String[] args) {
  15.         Student student1 = new Student();
  16.         student1.setFirstName("Mile");
  17.         student1.setLastName("Milevski");
  18.        
  19.         Student student2 = new Student();
  20.         student2.setFirstName("Toni");
  21.         student2.setLastName("Tomovski");
  22.        
  23.         Student student3 = new Student();
  24.         student3.setFirstName("Oki");
  25.         student3.setLastName("Okovski");
  26.        
  27.         List<Student> listStudent = new ArrayList<>();
  28.         listStudent.add(student1);
  29.         listStudent.add(student2);
  30.         listStudent.add(student3);
  31.        
  32.         for (Student student : listStudent) {
  33.             System.out.println("Ime: " + student.getFirstName());
  34.             System.out.println("Prezime: " + student.getLastName());
  35.         }
  36.         for (int i = 0;  i<listStudent.size(); i++) {
  37.             System.out.println("Primer2 Ime: " + listStudent.get(i).getFirstName());
  38.             System.out.println("Primer2 Prezime: " + listStudent.get(i).getFirstName());
  39.  
  40.         }
  41.     }
  42.  
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top