- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Samual Sam has Published 2491 Articles
Samual Sam
1K+ Views
Use the firstKey() method to get the lowest key stored in TreeMap.Let us first set the TreeMap and add some elements to it −TreeMap m = new TreeMap(); m.put(1, "PHP"); m.put(2, "jQuery"); m.put(3, "JavaScript"); m.put(4, "Ruby"); m.put(5, "Java"); m.put(6, "AngularJS"); m.put(7, "ExpressJS");Now get the lowest key −m.firstKey()The following is an ... Read More
Samual Sam
97 Views
The method java.io.File.isFile() is used to check whether the given file specified by the abstract path name is an existing file in Java. This method returns true if the file specified by the abstract path name is a file and false otherwise.A program that demonstrates this is given as follows ... Read More
Samual Sam
313 Views
The first element can be deleted from a LinkedList by using the method java.util.LinkedList.removeFirst(). This method does not have any parameters and it returns the first element of the LinkedList.The last element can be deleted from a LinkedList by using the method java.util.LinkedList.removeLast(). This method does not have any parameters ... Read More
Samual Sam
436 Views
The method java.io.File.canRead() is used to check whether the file can be read in Java. This method returns true if the file specified by the abstract path name can be read by an application and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class ... Read More
Samual Sam
4K+ Views
Elements can be added in the middle of an ArrayList by using the java.util.ArrayList.add() method. This method has two parameters i.e. the index at which to insert the element in the ArrayList and the element itself. If there is an element already present at the index specified by ArrayList.add() then ... Read More
Samual Sam
3K+ Views
The method java.io.File.getAbsolutePath() is used to obtain the absolute path name of a file or directory in the form of a string. This method requires no parameters.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo { public static void main(String[] args) { ... Read More
Samual Sam
88 Views
To get the count of NavigableMap in Java, use the size() method.Let us first create NavigableMap and add elements −NavigableMap n = new TreeMap(); n.put(5, "Tom"); n.put(9, "John"); n.put(14, "Jamie"); n.put(1, "Tim"); n.put(4, "Jackie");Now, get the count −n.size()The following is an example to implement the size() method to get the ... Read More
Samual Sam
1K+ Views
Use the lastKey() method to get the highest key stored in TreeMap.Let us first set the TreeMap and add some elements to it −TreeMap m = new TreeMap(); m.put(1, "PHP"); m.put(2, "jQuery"); m.put(3, "JavaScript"); m.put(4, "Ruby"); m.put(5, "Java"); m.put(6, "AngularJS"); m.put(7, "ExpressJS");Now get the highest key −m.lastKey()The following is an ... Read More
Samual Sam
75 Views
The length of the current file specified by the abstract path name can be displayed using the method java.io.File.length(). The method returns the file length in bytes and does not require any parameters.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo { public ... Read More
Samual Sam
241 Views
First, create a HashSet −HashSet hs = new HashSet();Now, add some elements using the add() method. Set the elements as a parameter. Here, we have set string −hs.add("B"); hs.add("A"); hs.add("D"); hs.add("E"); hs.add("C"); hs.add("F"); hs.add("K"); hs.add("M");The following is an example to add elements to a HashSet −Example Live Demoimport java.util.*; public class ... Read More