Svetlana_Ovsjanikova

java - MoreLists.examples

Sep 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package day6_morelists;
  7.  
  8. import java.util.ArrayList;
  9.  
  10. /**
  11. *
  12. * @author sao_7
  13. */
  14. public class examples {
  15.  
  16. public static void referenceSample(){
  17. ArrayList<String> sampleList = new ArrayList<String>();
  18.  
  19. sampleList.add("viens");
  20. sampleList.add("divi");
  21. sampleList.add("tris");
  22. sampleList.add("cetri");
  23.  
  24. int sampleInt = 5;
  25. sampleInt = changeInt(sampleInt);
  26. System.out.println("Arpus metodes- " + sampleInt);
  27.  
  28. outputList(sampleList);
  29. changeList(sampleList);
  30. outputList(sampleList);
  31. }
  32.  
  33. private static int changeInt(int number){
  34. number = number + 6;
  35. System.out.println("Ieksa metode- " + number);
  36. return number;
  37. }
  38.  
  39. private static void changeList(ArrayList<String> passList){
  40. passList.remove(0);
  41. //passList.isEmpty();
  42. }
  43.  
  44. private static void outputList(ArrayList<String>parList){
  45. System.out.println("Saraksts:");
  46. for (int i = 0; i < parList.size(); i++) {
  47. System.out.println("1) " + parList.get(i) + "");
  48. }
  49. }
  50. }
Add Comment
Please, Sign In to add comment