Palindrome Validation Using Java
We are well aware of validating a Palindrome string. The emphasize here is usage of StringBuffer/Builder and the reverse method to get the string reversed instead of using an interactive
We are well aware of validating a Palindrome string. The emphasize here is usage of StringBuffer/Builder and the reverse method to get the string reversed instead of using an interactive
Lambda expressions have simplified the way we write code. For example, let’s see how to use a method from an interface. This works with Java 1.8 only. Expected output: Welcome
Scanner is a simple and easy-to-use utility provided by Java. import java.util.Scanner;public class ScannerDemo{ public static void main(String args[]) { Scanner scanner = new Scanner(System.in); //Initializing the Scanner with the
The valueOf()Â method is useful when you do not know the value contained and it might throw a NullPointerException. It returns null and you can handle the same in your code
Improve Java performance with MAP. Add Contains keys Next Data StructureHashMap O(1) O(1) O(h/n) Hash TableEnumMap O(1) O(1) O(1) ArrayLinkedHashMap O(1) O(1) O(1) Hash Table+Linked ListTreeMap O(log n) O(log n)
We can see that the method println is referred by System.out using :: import java.util.*;public class NewForEach { public static void main(String args[]) { List empNames = new ArrayList(); empNames.add(“Andrew”);
Java collections – performance (Time Complexity) A set is a collection that contains no duplicate elements. Add Next Contains Data StructureHashSet O(1) O(h/n) O(1) Hash TableEnumSet O(1) O(1) O(1) Bit
Files have multiple properties and they are interesting to use. In fact, your own file system can be developed using them. Create a file named PATH.txt and try this program
Java collections – performance (Time Complexity) A list is an ordered collection of elements. Add Remove Get Contains Data StructureArrayList O(1) O(n) O(1) O(n) ArrayCopyonWriteArrayList O(n) O(n) O(1) O(n) ArrayLinkedList