Following is an example to implement Decade Class from Ennead Class in Java using JavaTuples −Exampleimport org.javatuples.Decade; import org.javatuples.Ennead; public class MyDemo { public static void main(String[] args) { Ennead e = Ennead.with("Katie", "Tom", "Ryan", "Tom", "Bradley", "David", "Steve", "Brad", "Jacob"); System.out.println("Ennead elements= " + e); Decade decade = e.add("Amy"); System.out.println("Decade elements (implemented from Ennead) = " + decade); } }OutputEnnead elements= [Katie, Tom, Ryan, Tom, Bradley, David, Steve, Brad, Jacob] Decade elements (implemented from Ennead) = [Katie, Tom, Ryan, Tom, Bradley, ... Read More
To sort TreeSet in descending order, use the descendingSet() method in Java.The descendingSet() method is used to return a reverse order view of the elements contained in this set.At first, create a TreeSet −TreeSet treeSet = new TreeSet();Then add some elements −treeSet.add(45); treeSet.add(15); treeSet.add(99); treeSet.add(70);Sort them indecreasing order −TreeSet res = (TreeSet)treeSet.descendingSet();Following is the code to sort TreeSet in descending order −Example Live Demoimport java.util.TreeSet; public class Main { public static void main(String[] args) { TreeSet treeSet = new TreeSet(); treeSet.add(45); treeSet.add(15); treeSet.add(99); treeSet.add(70); ... Read More
To sort HashSet in Java, you can use another class, which is TreeSet.Following is the code to sort HashSet in Java −Example Live Demoimport java.util.*; public class Main { public static void main(String args[]) { Set hashSet = new HashSet(); hashSet.add("green"); hashSet.add("blue"); hashSet.add("red"); hashSet.add("cyan"); hashSet.add("orange"); hashSet.add("green"); System.out.println("HashSet elements"+ hashSet); Set treeSet = new TreeSet(hashSet); System.out.println("Sorted elements"+ treeSet); } }OutputHashSet elements [red, orange, green, blue, cyan] Sorted elements [blue, cyan, ... Read More
When you call a method at illegal or inappropriate time an IlleagalStateException is generated.For example, the remove() method of the ArrayList class removes the last element after calling the next() or previous methods.After removing the element at the current position you need to move to the next element to remove it i.e. per one call of the next() method you can invoke this remove() method only once.Since the initial position of the list (pointer) will be before the first element, you cannot invoke this method without calling the next method.If you invoke the remove() method otherwise it throws an java.lang.IllegalStateException.Example: ... Read More
The HTML DOM table deleteTFoot() method delete the element from the table in an HTML document.SyntaxFollowing is the syntax −object.deleteTFoot()Let us see an example of HTML DOM table deleteTFoot() method −Example Live Demo body { color: #000; background: lightblue; height: 100vh; text-align: center; } table { margin: 2rem auto; } caption { color: #db133a; } .btn { background: #db133a; border: none; height: 2rem; ... Read More
The HTML DOM table deleteCaption() method delete the first element from the table in an HTML document.SyntaxFollowing is the syntax −object.deleteCaption()Let us see an example of HTML DOM table deleteCaption() method −Example Live Demo body { color: #000; background: lightblue; height: 100vh; text-align: center; } table { margin: 2rem auto; } caption { color: #db133a; } .btn { background: #db133a; border: none; height: 2rem; ... Read More
The HTML DOM table insertRow() method generates an empty element and adds it to the table in an HTML document.SyntaxFollowing is the syntax −object.insertRow(index)Here, index represent a number that specifies the position of the row to insert.Let us see an example of HTML DOM table insertRow() method −Example Live Demo body { color: #000; background: lightblue; height: 100vh; text-align: center; } table { margin: 2rem auto; } caption { color: #db133a; } .btn ... Read More
The HTML DOM table createTHead() method generates an empty element and adds it to the table in an HTML document.SyntaxFollowing is the syntax −object.createTHead()Let us see an example of HTML DOM table createTHead() method −Example Live Demo body { color: #000; background: lightblue; height: 100vh; text-align: center; } table { margin: 2rem auto; } caption { color: #db133a; } .btn { background: #db133a; border: none; ... Read More
The HTML DOM table createTFoot() method generates an empty element and adds it to the table in an HTML document.SyntaxFollowing is the syntax −object.createTFoot()Let us see an example of HTML DOM table createTFoot() method −Example Live Demo body { color: #000; background: lightblue; height: 100vh; text-align: center; } table { margin: 2rem auto; } caption { color: #db133a; } .btn { background: #db133a; border: none; ... Read More
The HTML DOM table createCaption() method generates an empty element and adds it to the table in an HTML document.SyntaxFollowing is the syntax −object.createCaption()Let us see an example of HTML DOM table createCaption() method −Example Live Demo body { color: #000; background: lightblue; height: 100vh; text-align: center; } table { margin: 2rem auto; } caption { color: #db133a; } .btn { background: #db133a; border: none; ... Read More