Uncategorized

Color scheme

Collections All Methods – At a Glance Reversing elements with reverse() How many times element occurs with frequency() Replacing elements with replaceAll() Finding Min and Max values with min() and max() Sorting ArrayList with Collections sort() Sorting ArrayList with Collections sort() Comparator Searching an element with binarySearch() Copying one list to another with copy() Swapping …

Color scheme Read More »

Java Scanner class

To make coding less, the Designers introduced java.util.Scanner (Scanner is not from java.io package) in Java 5. Earlier to Java Scanner class, keyboard input was taken using DataInputStream and BufferedReader, both requiring extra code of parsing the user input. Java Scanner avoids parsing. Example on Java Scanner taking Keyboard input import java.util.Scanner; public class KeyboardScanner …

Java Scanner class Read More »

Get Super classes of a Class Java Reflection API

It is advised to read the notes on Java Reflection API before attempting the programs. Example to get super classes of a class with Java Reflection API import java.awt.Button; import java.lang.reflect.Modifier; class Test { } class Hello extends Test { } public class Demo extends Hello { public static void main(String [] args) { Demo …

Get Super classes of a Class Java Reflection API Read More »