- PriorityQueue/ Queue to List conversion
List<String> array_list = new ArrayList<String>(pq1);
- Split string based on spaces/tab
// \s is regular expression for space. + stands for more than one space str.split("\\s+");
- Compare two double
Double.compare(doubel, double2)
- Dimesnsion of 2D array
// 2 D array arr[][] int rows = arr.length; // Numbers of column in row 0 int colums = arr[0].length;
- Trim whitespace from front and end of string
// Trim whitespace from 'str' str.trim();
- Integer to Char
// Convert integer 'i' to char based on th base 'RADIX' char ch = Character.forDigit(i, RADIX); // Another way int i = 1; char b = (char)(i + 'a');
- Moving data from a HashSet to ArrayList
Set<String> hSet = new HashSet<String>(); // Add values hSet.add("Set"); hSet.add("List"); List<String> list = new ArrayList<String>(hSet);
- Access values of HashMap
// map.values() gives a Collection with all the values in HashMap HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); Collection<Integer> values = map.values(); // ArrayList has a constructor that accepts a collection. List<Integer> valuesList = new ArrayList<Integer>(values);
Sharing is Caring !
Subscribe
0 Comments
Most Voted