Currently working on it will come back with a bang bang ..... ! Don't forget to star A lot of content is going to be here
char ch[] = s.toCharArray();
- Char Array to String
Adding all char array character to a single string String.valueOf(chararr);
- Reversing a string StringBuilder s = new StringBuilder("String"); s.reverse()
-
Converting Arrays to list You can only convert wrapper class to list Integer arr[] = {blah....}; list<Object> al = Arrays.asList(arr);
-
Array fill
Filling array with same number
Array.fill(arr,-1); -
Array Equal Return boolean comparing arrays
Arrays.equals(arr1,arr2); -
Array Sort Sorting array
Arrays.sort(arr); -
Array BinarySearch Searching a number using binarySearch
Arrays.binarySearch(arr,10);
- Enhanced Get Element
Used in insertion of frequency
hm.getOrDefault(arr[i],0)+1 ;
hm.put(arr[i],hm.getOrDefault(arr[i],0)+1) - Iterator
HashMap<Integer,String> languages;
for (Entry<Integer,String> entry : languages.entrySet()) {
System.out.print(entry.getKey());
System.out.print(entry.getValue());
}
- MIN Heap
PriorityQueue<Integer> pq = new PriorityQueue<>((a,b)->a-b);
- MAX Heap
PriorityQueue<Integer> pq = new PriorityQueue<>((a,b)->b-a);
-
If statement return a value
(a>b) ? true : false ; -
String T to T
Double.parseDouble("1.223") Integer.parseInt("123") Float.parseFloat("23.23") -
Decimal after point till x
double d1 = 1.23232
DecimalFormat df = new DecimalFormat()
d1 = df.format(d1)