Java TreeSet remove() methodThe remove() method of TreeSet class is used to delete/remove elements from the set. Syntax:Parameter:o - element to be removed from the set. Return:It returns true if set contain specified element Example 1Output: TreeSet: [ 1, 2, 5, 8, 10 ] TreeSet: true TreeSet: [1, 2, 8, 10 ] Example 2Output: TreeSet: [ A, B, a, b ] TreeSet: true TreeSet: [A, a, b ] Example 3Output: TreeSet: [ A, B, a, b ] [ 1, 3, 6, 9 ] TreeSet: true TreeSet: [ A, B, a, b ] [ 1, 6, 9 ] TreeSet: true TreeSet: [ B, a, b ] [ 1, 6, 9 ] Example 4Output: Javac TreeSetremove4.java Java TreeSetremove4 TreeSet: [1, 3, 6, 9, A, B, a, b] TreeSet: false TreeSet: [1, 3, 6, 9, A, B, a, b] Next TopicJava-treeset-spliterator-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India