Advertisement
MrDoyle

11) Arrays of Strings

Jan 14th, 2021
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. public class Main {
  2.  
  3.     public static void main(String []args){
  4.  
  5.         String[] words = new String[3];
  6.  
  7.         words [0] = "Hello";
  8.         words[1] = "to";
  9.         words[2] = "you";
  10.  
  11.         System.out.println(words[0]);
  12.         System.out.println(words[1]);
  13.         System.out.println(words[2]);
  14.  
  15.  
  16.         String[] fruits = {"apple", "banana" , "pear", "kiwi"};
  17.  
  18.         System.out.println(fruits[0]);
  19.         System.out.println(fruits[1]);
  20.         System.out.println(fruits[2]);
  21.         System.out.println(fruits[3]);
  22.  
  23.         for (String fruit: fruits){
  24.             System.out.println(fruit);
  25.         }
  26.  
  27.         int value = 0;
  28.         String text = null;
  29.         System.out.println(text);
  30.  
  31.         String[] texts = new String[2];
  32.         System.out.println(texts[0]);
  33.  
  34.         texts[0] = "one";
  35.         System.out.println(texts[0]);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement