![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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 9326 Articles for Object Oriented Programming
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
12K+ Views
To display Boolean type, firstly take two variables and declare them as boolean.boolean val1, val2;Then one by one assign values to both of them, one of them is shown below −val1 = true;Now, use if statement to check and display the Boolean true value.if(val1) System.out.println("This is true and will get displayed!");Let us now see the complete example to work with Boolean Type in Java.Example Live Demopublic class Demo { public static void main(String[] args) { boolean val1, val2; System.out.println("Boolean Type in Java"); val1 = true; if(val1) ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
832 Views
Overflow occurs when the given value is more than the maximum prescribed size of a data type. The overflow condition can result to an error or now the implementation of the programming language handles it on its own.To display overflow of datatypes, I have taken an example of float datatype. Float data type is a single-precision 32-bit IEEE 754 floating point.The range of a float datatype is −approximately ±3.40282347E+38FThe following program display overflow of datatypes in Java.Example Live Demopublic class Demo { public static void main(String[] args) { System.out.println("Displaying Overflow... "); float val1 = ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
3K+ Views
Every data type in Java has a minimum as well as maximum range, for example, for Float.Min = 1.4E-45 Max = 3.4028235E38Let’s say for Float, if the value extends the maximum range displayed above, it leads to Overflow.However, if the value is less than the minimum range displayed above, it leads to Underflow.The following is the Java Program to display the minimum and maximum value of primitive data types.Example Live Demopublic class Demo { public static void main(String[] args) { System.out.println("Integer Datatype values..."); System.out.println("Min = " + Integer.MIN_VALUE); System.out.println("Max = " ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
12K+ Views
Primitive datatypes are predefined by the language and named by a keyword in Java. Here is an example to display the default value of primitive data types.Example Live Demopublic class Demo { static boolean val1; static double val2; static float val3; static int val4; static long val5; static String val6; public static void main(String[] args) { System.out.println("Default values....."); System.out.println("Val1 = " + val1); System.out.println("Val2 = " + val2); System.out.println("Val3 = " + val3); System.out.println("Val4 = " + val4); ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
4K+ Views
A stack and a heap are used for memory allocation in Java. However, the stack is used for primitive data types, temporary variables, object addresses etc. The heap is used for storing objects in memory.Stacks and heaps in Java are explained in more detail as follows −Stack in JavaStacks are used to store temporary variables, primitive data types etc. A block in the stack exists for a variable only as long as the variable exists. After that, the block data is erased and it can be used for storing another variable.
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
539 Views
This example shows how to search the minimum and maximum element in an array by using Collection.max() and Collection.min() methods of Collection class.Example Live Demoimport java.util.Arrays; import java.util.Collections; public class Main { public static void main(String[] args) { Integer[] numbers = { 8, 2, 7, 1, 4, 9, 5}; int min = (int) Collections.min(Arrays.asList(numbers)); int max = (int) Collections.max(Arrays.asList(numbers)); System.out.println("Min number: " + min); System.out.println("Max number: " + max); } }OutputThe above code sample will produce the following result.Min number: 1 Max number: 9Another ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
1K+ Views
In order to get frequency of each in a string in Java we will take help of hash map collection of Java.First convert string to a character array so that it become easy to access each character of string.Now compare for each character that whether it is present in hash map or not in case it is not present than simply add it to hash map as key and assign one as its value.And if character is present than find its value which is count of occurrence of this character in the string (initial we put as 1 when it ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
511 Views
Fibonacci numbers of Fibonacci series grows exponentially and can be very large for large numbers like 500 or 1000. To handle such number, long data type is not sufficient. BigInteger can handle large number easily. BigInteger is useful in scenarios where calculations results in data which is out of limit for available primitive data types. See the example below of getting Fibonacci number of 100 and 1000.Example Live Demoimport java.math.BigInteger; public class Tester { public static void main(String args[]) { System.out.println("Fibonacci of 100: "); System.out.println(fibonacci(100)); System.out.println("Fibonacci of 1000: "); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
384 Views
As we know that Java needs main() method to be static in the public class to make it executable. The prime reason for this requirement is to make JVM enable to call the main() method without creating an object. That simply means that JVM does not create the object of the Main class which contains the main() method. To justify the same, we can make the Main class containing the main method as abstract and program still runs.Following example showcases the same. Here we have made the main class abstract.Exampleabstract public class Tester { public static void main(String args[]) ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
530 Views
x++ automatically handles the type casting where as x= x + 1 needs typecasting in case of x is not an int variable. See the example below.Example Live Demopublic class Tester { public static void main(String args[]) { byte b = 2; //Type casting is required //as 1 is int and b is byte variable b = (byte) (b + 1); System.out.println(b); byte b1 = 2; //Implcit type casting by the compiler b1++; System.out.println(b1); } }Output3 3