What is Java ? is explained in Simple terms for a Beginner to get an idea of Java. Java, developed by Sun Microsystems and released to market in 1995, is a high-level programming language with many unparalleled features. It can be used to develop standalone applications, web applications (applets and…
JDK 1.8 Features
Following are JDK 1.8 Features Read one-by-one as they are very innteresting. 1. Method References a) With static method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import java.util.Arrays; class Test { public static int matchStringLength(String str1, String str2) { return str1.length() - str2.length(); } } public class Demo { public void printByStringLength() { String names[] = {"abcde","abc","ab","abcd", "a"}; Arrays.sort(names, Test::matchStringLength); System.out.println(Arrays.toString(names)); } public static void main(String args[]) { new Demo().printByStringLength(); } } |
Arrays.sort(names, Test::matchStringLength); You can call the methods with their names (references) with :: operator. 2. Parallel Sort
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import java.util.Arrays; public class Demo { public static void main(String args[]) { String fruits[] = {"guava","apple","banana"}; String fruits1[] = {"guava","apple","banana"}; // before JDK 1.8, using Arrays.sort() Arrays.sort(fruits); System.out.println(Arrays.toString(fruits)); // with JDK 1.8, using Arrays.parallelSort() Arrays.parallelSort(fruits1); System.out.println(Arrays.toString(fruits1)); } } |
Both sort() and parallelSort() sorts the array. The performance with parallelSort() can…
Java Programming
When you start learning a new language, you fear a lot thinking how much trouble to face and concentration is required, as this is the impression left by C/C++ while you learnt. Remember one thing, Java Designers always aim only two things while developing the language – how to make…
Basic Java
Java is an easy language to learn and practice, everyone accepts. Especially, C/C++ Students feel Java is very easy as Java does not support pointers. We write Linked List program in Java without pointers. Something strange, you feel. It is true. All discussed briefly in this tutorial Basic Java and…
Java Learning
Java learning is simple due to no pointers support. C/C++ Programmers can reach Java easily as Java borrowed many concepts like data type rules, control structures and arrays from C/C++. But for learning Java, C++ background is not essential as the same OOPS concepts of C++ are learnt though Java…