Skip to content

Instantly share code, notes, and snippets.

@shershen08
Last active January 9, 2019 20:37
Show Gist options
  • Save shershen08/f3bc1855b20119d135e59eb2004d831b to your computer and use it in GitHub Desktop.
Save shershen08/f3bc1855b20119d135e59eb2004d831b to your computer and use it in GitHub Desktop.
Java basics

Array and List Array

 //Initializing Boolean array;
 Boolean[] BooleanArray;

 //Initializing Boolean array list;
 List<Boolean> BooleanArrayList = new ArrayList<>();

//add items in list
 BooleanArrayList.add(true);
 BooleanArrayList.add(false);
 
 //get size and item of the List -  ArrayList<>
 BooleanArrayList.size();
 BooleanArrayList.get(i);
 
 //get size and item of the Array -  Boolean[]
 BooleanArray.length;
 BooleanArray[j];
 
 //Converting Boolean array list into Boolean array.
 BooleanArray = BooleanArrayList.toArray(new Boolean[BooleanArrayList.size()]);

String and Array

//new strings array
String[] stringArray = new String[]{
 
 "One",
 "Two",
 "Three",
 "Four",
 "Five"
 };
 
 //get length and item
 stringArray.length;
 stringArray[i];
 
 //Converting string array to string
 DemoValue = Arrays.toString(stringArray)
 
 //use string builder
 StringBuilder stringbuilder = new StringBuilder();
 //for in 
 stringbuilder.append(stringArray[i]);
 //after
 stringbuilder.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment