Shriansh Kumar has Published 173 Articles

Different Ways to Copy Files in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 22:05:36

646 Views

Java provides different ways to copy files including the ‘File’, ‘FileInputStream’ and‘FileOutputStream’ classes. There are times when we need to take a backup, compress a file or share it with others. In these situations, copying that file becomes necessary. Weare going to explore the methods and classes that will help ... Read More

Different Method Calls in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 21:40:19

84 Views

Java provides different method calls techniques that we can use according to the need andscenario in our program. Here, methods mean a block of code that can be reused multipletimes to perform a single operation. It saves our time and also reduces the size of code.The method call is referred ... Read More

How are parameters passed in Java?

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 21:19:58

781 Views

The most frequent query asked by beginner programmers is that how are parameters passed in Java. Generally, the programming languages use pass by value and pass byreference for passing parameters to a method. However, Java does not support both approaches rather it uses pass by value to pass both primitive ... Read More

Different Ways to Create the Instances of Wrapper Classes in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 21:14:47

198 Views

To encapsulate or represent a primitive datatype within an object, Java provides theconcept of Wrapper classes. All eight wrapper classes are as follows Double, Float, Long, Integer, Short, Byte, Character, and Boolean. These classes have a variety of in-builtmethods that allows us to integrate primitives into their respective instances as ... Read More

Different Ways to Print First K Characters of the String in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 21:09:15

83 Views

A string is a class in Java that stores a series of characters enclosed within double quotes.Those characters are actually String-type objects. The string class is available in the‘java.lang’ package. Suppose we have given a string and a positive integer ‘k’. Now, thejob is to print that string's first 'k' ... Read More

Getting Least Value Element From a Set by Using Sorting Logic on TreeSet in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 21:06:28

40 Views

TreeSet is a class of Java Collection Framework that implements the SortedSet Interface.It stores elements in ascending order and does not allow duplicate values therefore, theaccess and retrieval time becomes faster. Because of this excellent feature, TreeSet isfrequently used to store large amounts of information that need to be searched ... Read More

Getting Highest and Lowest Value Element From a Set by using Sorting Logic on TreeSet in Java

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 21:02:54

49 Views

TreeSet is a class of Java Collection Framework that implements the SortedSet Interface.It stores elements in ascending order and does not allow duplicate values therefore, theaccess and retrieval time becomes faster. Because of this excellent feature, TreeSet isfrequently used to store large amounts of information that need to be searched ... Read More

How to Add Custom Class Objects to the TreeSet in Java?

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 20:14:00

601 Views

TreeSet is a class of Java Collection Framework that implements the SortedSet Interface. Remember that it stores elements in ascending order and does not allow duplicate values. We need to stick with this condition while adding custom class objects to the TreeSet otherwise we will encounter a ClassCastException. Here, custom ... Read More

How to add an element to an Array in Java?

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 20:10:49

10K+ Views

Array is a linear data structure that is used to store a group of elements with similar datatypes. It stores data in a sequential manner. Once we create an array we can’t change its size i.e. it is of fixed length. Adding an element to a given array is a ... Read More

How do I generate random integers within a specific range in Java?

Shriansh Kumar

Shriansh Kumar

Updated on 20-Jul-2023 20:07:50

551 Views

Suppose we are in a situation where we need to generate random integer numbers within a specific range through Java programs. For the given scenario, there are two distinct ways available in Java. We can use either the Random class or random() method. Let’s discuss them in the next section. ... Read More

Previous 1 ... 4 5 6 7 8 ... 18 Next
Advertisements