- 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
Found 9321 Articles for Object Oriented Programming
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
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 to as invocation of methods. To use the functionality of amethod, it must be invoked by some means. This article aims to explain how methods arecalled in Java User-defined Method in Java Before discussing the method call, let’s familiarize ourselves with syntax of the userdefined methods Syntax accessSpecifier nonAccessModifier return_Type ... Read More
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
171 Views
In Java, every interface, class, object, variable and method of a running program is stored in distinct reasons of computer memory. The heap is the part of memory area where values of variables, methods and classes are stored at runtime. Its allocation happens dynamically and can grow or shrink depending on the application's needs. On the other hand, the reference variables, names of methods and classes are stored in the stack memory area. However, if for some reason their allocation is not handled properly then, it may lead to memory errors that we are going to discuss in this article. ... Read More
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
782 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 and reference type values. In this article, we are going to understand passing parameters by value through exampleprograms. Passing Parameters to a Method in Java Let’s start this discussion by understanding the storage mechanism of Java. The referencevariables, names of methods and classes are stored in stack and their values ... Read More
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
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 well asdisintegrate instances into their respective primitive datatypes. This article aims to explainthe different ways to create instances of Wrapper Classes. Creating Instances of Wrapper Classes The following approaches are available in Java to create Instances of Wrapper Classes − With the help of Constructor Although we can create an ... Read More
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
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' characters in Java. Also, check whether the length ofgiven string is less than or not, if so print the original string. Java Program to Print First K Characters of the String Let’s understand the given problem with a few examples − Instance String st1 = “TutorialsPoint”; String st2 = “Tutorial”; ... Read More
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
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 quickly.We will use the Comparable Interface to sort the given TreeSet and then using in-builtmethod named ‘first()’, we try to get the least value element from that TreeSet. Java Program to get Least value element from TreeSet Before jumping into the program, let’s familiarize ourselves with a few concepts − ... Read More
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
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 quickly.We will use the Comparable Interface to sort the given TreeSet and then using in-builtmethods, we try to get the highest and lowest value elements from that TreeSet. Java Program to get Highest and Lowest value elements from TreeSet Before jumping into the program, let’s familiarize ourselves with a few ... Read More
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
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 class objects mean userdefined objects that are created with the help of a constructor. Program to add Custom Class Objects to the TreeSet Earlier in the previous section, we discussed that if we failed to follow the condition of TreeSet, we will get a ClassCastException. To avoid this, we need ... Read More
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
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 vastly common operation. In this article, we will discuss how to add an element to an Array through Java example programs. Adding an element to an Array in Java Let’s understand the operation with an example first − We will add a new element ‘50’ at the end ... Read More
![Shriansh Kumar](https://www.tutorialspoint.com/assets/profiles/644826/profile/60_1575483-1682416785.jpg)
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. Generate Random Integers within a Specific Range We are going to use the following class and method − Random Class We create an object of this class to return pseudorandom numbers within a given range.We will customize this object and apply our own logic to generate any random valueswithin the ... Read More