- 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
Krantik Chavan has Published 308 Articles
Krantik Chavan
699 Views
Use HTMLEditorKitt to change the font size with HTML. With that, use the JEditorPane setText() method to set HTML:HTMLEditorKit kit = new HTMLEditorKit(); editorPane.setEditorKit(kit); editorPane.setSize(size); editorPane.setOpaque(true); editorPane.setText(" This is a demo text with a different font!");The following is an example to change font size with HTML in Java Swing JEditorPane:Exampleimport ... Read More
Krantik Chavan
565 Views
An immutable copy of the LocalDate where the years are subtracted from it can be obtained using the minusYears() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of years to be subtracted and it returns the instant with the subtracted years.A program ... Read More
Krantik Chavan
83 Views
The addAll() method of the AbstractCollection class in Java is used to add all of elements in the specified collection to this collection. It returns TRUE if the elements are successfully appendedThe syntax is as follows:public boolean addAll(Collection
Krantik Chavan
84 Views
Let’s say we have the following string:String str = "YuBM787Nm";Now to display it as IntStream, use filter() and map() as shown below:int res = str.chars() .filter(Character::isDigit) .map(ch → Character.valueOf((char) ch)).sum();The following is an example to display string as IntStream:Examplepublic class Demo { public static void main(String[] args) { ... Read More
Krantik Chavan
154 Views
The day of the week for a particular LocalDate can be obtained using the getDayOfWeek() method in the LocalDate class in Java. This method requires no parameters and it returns the day of the week.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo { ... Read More
Krantik Chavan
505 Views
Use the setPage() method of the JEditorPane to display a webpage:JEditorPane editorPane = new JEditorPane(); editorPane.setPage("https://www.tutorialspoint.com");The following is an example to display a webpage in JEditorPane:Exampleimport java.io.IOException; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JScrollPane; public class SwingDemo { public static void main(String[] args) { JEditorPane editorPane = ... Read More
Krantik Chavan
248 Views
At first, let us create and array of strings:String[] strArr = { "ABCD", "AB", "ABCDEFG", "ABC", "A", "ABCDE", "ABCDEF", "ABCDEFGHIJ" }Now, for longest to shortest pattern, for example ABCDEFGHIJ, ABCDEFG, ABCDEF, etc.; get the length of both the string arrays and work them like this:Arrays.sort(strArr, (str1, str2) → str2.length() - ... Read More
Krantik Chavan
418 Views
Let us first declare and initialize an Integer array:Integer[] arr = {20, 50, 75, 100, 120, 150, 170, 200};To find the reverse of the Integer array with Lambda, use sort and the Lamda:Arrays.sort(arr, (Integer one, Integer two) -> { return (two- one); });The following is an example to reverse an Integer ... Read More
Krantik Chavan
4K+ Views
First, create a List with String elements:List myList = new ArrayList(); myList.add("pqr"); myList.add("stu"); myList.add("vwx"); myList.add("yza"); myList.add("bcd"); myList.add("efg"); myList.add("vwxy");Use the startsWith() method to check if any of the above string in the myList begins with a specific letter:myList.stream().anyMatch((a) -> a.startsWith("v"));TRUE is returned if any of the string begins with the specific ... Read More
Krantik Chavan
424 Views
The day of the month for a particular LocalDate can be obtained using the getDayOfMonth() method in the LocalDate class in Java. This method requires no parameters and it returns the day of the month which can be in the range of 1 to 31.A program that demonstrates this is ... Read More