SHARE
TWEET

arrays

a guest Sep 22nd, 2019 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //arrays
  2. //java -> int grades[] = new int[5];
  3.  
  4. var grades:[Int] = []
  5. grades.append(85)
  6. grades.append(60)
  7. grades.append(100)
  8.  
  9. //java for print array - need to use array
  10. print (grades)
  11. print ("michel grade \(grades[0])")
  12.  
  13. grades.insert(98, at:1)
  14. print (grades)
  15.  
  16. var imn:[String] = []
  17. imn.insert("Neo", at:0)
  18. imn.insert("Michel", at:0)
  19. imn.insert("Noah", at:0)
  20.  
  21. print (imn)
  22.  
  23. //declare an array with some data
  24. var students:[String] = ["Gal","Nick","Jordon","Fuz da pu"]
  25. print (students)
  26. students.append("Elad")
  27. print (students)
  28. var studentIsHere=students.contains("Shlomi")
  29. print ("Shlomi is here? \(studentIsHere)")
  30.  
  31. print ("------------------------")
  32. var myArrayCount = [String](repeating:"1", count:10)
  33. print (myArrayCount)
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