Raja has Published 760 Articles

How to compile & run a Java program using Command Prompt?

raja

raja

Updated on 17-Nov-2023 14:04:11

16K+ Views

While many programming environments allow us to compile and run a program within the environment, we can also compile and run java programs using Command Prompt.After successful installation of JDK in our system and set the path, we can able to compile and execute Java programs using the command prompt. Step ... Read More

How to implement an interface using an anonymous inner class in Java?

raja

raja

Updated on 17-Nov-2023 08:41:15

1K+ Views

An anonymous inner class is a class which doesn't have a name, we will directly define it at the instantiation line. Example In the following program, we are implementing the toString() method of TutorialsPoint interface using Anonymous inner class and, print its return value. interface TutorialsPoint{ public String toString(); } public class Main ... Read More

How to access the JSON fields, arrays and nested objects of JsonNode in Java?

raja

raja

Updated on 25-Oct-2023 14:06:16

24K+ Views

A JsonNode is Jackson's tree model for JSON and it can read JSON into a JsonNode instance and write a JsonNode out to JSON. To read JSON into a JsonNode with Jackson by creating ObjectMapper instance and call the readValue() method. We can access a field, array or nested object using the get() ... Read More

How can we read from standard input in Java?

raja

raja

Updated on 22-Oct-2023 13:24:29

26K+ Views

The standard input(stdin) can be represented by System.in in Java. The System.in is an instance of the InputStream class. It means that all its methods work on bytes, not Strings. To read any data from a keyboard, we can use either a Reader class or Scanner class.Example1import java.io.*; public class ... Read More

Can we execute a java program without a main method?

raja

raja

Updated on 07-Oct-2023 02:45:53

24K+ Views

Yes, we can execute a java program without a main method by using a static block.  Static block in Java is a group of statements that gets executed only once when the class is loaded into the memory by Java ClassLoader, It is also known as a static initialization block. ... Read More

How to get the values of the different types from a JSON object in Java?

raja

raja

Updated on 14-Sep-2023 21:54:22

26K+ Views

A JSONObject is an unordered collection of name/value pairs and parses text from a String to produce a map-like object. A JSONObject has few important methods to display the values of different types like getString() method to get the string associated with a key string, getInt() method to get the int value associated with ... Read More

How to read the data from a properties file in Java?

raja

raja

Updated on 14-Sep-2023 14:00:27

26K+ Views

The Properties is a subclass of Hashtable class and it represents a persistent set of properties. The Properties can be saved to a stream or loaded from a stream. Each key and its corresponding value in the property list is a string. The Properties file can be used in Java to externalize the ... Read More

What is a constant and how to define constants in Java?

raja

raja

Updated on 14-Sep-2023 02:01:33

27K+ Views

A constant is a variable whose value cannot change once it has been assigned. Java doesn't have built-in support for constants.A constant can make our program more easily read and understood by others. In addition, a constant is cached by the JVM as well as our application, so using a ... Read More

What is the use of setBounds() method in Java?

raja

raja

Updated on 13-Sep-2023 03:56:20

31K+ Views

The layout managers are used to automatically decide the position and size of the added components. In the absence of a layout manager, the position and size of the components have to be set manually. The setBounds() method is used in such a situation to set the position and size. To specify the ... Read More

How can we convert a list to the JSON array in Java?

raja

raja

Updated on 12-Sep-2023 02:54:07

29K+ Views

The JSON is a lightweight, text-based and language-independent data exchange format. The JSON can represent two structured types like objects and arrays. An object is an unordered collection of key/value pairs and an array is an ordered sequence of values.We can convert a list to the JSON array using the JSONArray.toJSONString() method and it is ... Read More

Previous 1 ... 7 8 9 10 11 ... 76 Next
Advertisements