- 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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
39K+ Views
To check whether a character is in Uppercase or not in Java, use the Character.isUpperCase() method.We have a character to be checked.char val = 'K';Now let us use the Character.isUpperCase() method.if (Character.isUpperCase(val)) { System.out.println("Character is in Uppercase!"); }else { System.out.println("Character is in Lowercase!"); }Let us see the complete example now to check for Uppercase in Java.Example Live Demopublic class Demo { public static void main(String []args) { System.out.println("Checking for Uppercase character..."); char val = 'K'; System.out.println("Character: "+val); if (Character.isUpperCase(val)) { System.out.println("Character is ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
515 Views
To display printable characters, you need to work with the ASCII values from 32 to 127.With that, we are using the following, instead of System.out.println()System.out.write();The following displays all the printable characters.for (int i = 32; i < 127; i++) { System.out.write(i);Let us see the complete example.Example Live Demopublic class Demo { public static void main(String []args) { System.out.println("Printable characters..."); for (int i = 32; i < 127; i++) { System.out.write(i); if (i % 8 == 7) System.out.write(''); else ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
To assign int value to a char variable in Java would consider the ASCII value and display the associated character/ digit.Here, we have a char.char val;Now assign int value to it.val = 77;Now, when you will print the value of “val”, it would display the character associate with the value (ASCII) 77.The following is the complete example.Example Live Demopublic class Demo { public static void main(String []args) { char val; val = 77; System.out.print("Value: "); System.out.println(val); } }OutputValue: M
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
To reverse an integer in Java, try the following code −Example Live Demoimport java.lang.*; public class Demo { public static void main(String[] args) { int i = 239, rev = 0; System.out.println("Original: " + i); while(i != 0) { int digit = i % 10; rev = rev * 10 + digit; i /= 10; } System.out.println("Reversed: " + rev); } }OutputOriginal: 239 Reversed: 932In the above program, we have the following int value, which we will reverse.int i = 239;Now, loop through until the value is 0. Find the remainder and perform the following operations to get the reverse of the given integer 239.while(i != 0) { int digit = i % 10; rev = rev * 10 + digit; i /= 10; }
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
448 Views
To compare two Java short arrays, use the Arrays.equals() method.Let us first declare and initialize some int arrays.int[] arr1 = new int[] { 33, 66, 12, 56, 99 }; int[] arr2 = new int[] { 33, 66, 12, 56, 99 }; int[] arr3 = new int[] { 33, 66, 15, 56, 90 };Now let us compare any two of the above arrays.Arrays.equals(arr1, arr2));In the same way, work it for other arrays and compare themExample Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { int[] arr1 = new int[] { 33, 66, 12, 56, ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
967 Views
To pass an integer by reference in Java, try the following code −Example Live Demopublic class Demo { public static void display(int[] arr) { arr[0] = arr[0] + 50;; } public static void main(String[] args) { int val = 50; int[] myArr = { val }; display(myArr); System.out.println(myArr[0]); } }Output100In the above program, a custom method is created, which pass an int array.int val = 50; int[] myArr = { val }; display(myArr);In the method, we have performed mathematical operation on the value of array.public static void display(int[] arr) { arr[0] = arr[0] + 50;; }The updated value is then displayed in the main.System.out.println(myArr[0]);
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
216 Views
To parse and format to hexadecimal in Java, we have used the BigInteger class. The java.math.BigInteger class provides operations analogues to all of Java's primitive integer operators and for all relevant methods from java.lang.Math.In the below example, we have taken BigInteger and created an object. With that, some values have been set by us in the arguments as the hexadecimal and the radix i.e. 16 for hexadecimal.BigInteger bi = new BigInteger("2ef", 16);Let us see an example.Example Live Demoimport java.math.*; public class Demo { public static void main( String args[] ) { BigInteger bi = new BigInteger("2ef", 16); ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
311 Views
To parse and format a number to decimal, try the following code.Example Live Demopublic class Demo { public static void main( String args[] ) { int val = Integer.parseInt("5"); String str = Integer.toString(val); System.out.println(str); } }Output5In the above program, we have used the Integer.parseInt() and Integer.toString() method to convert a number to decimal.int val = Integer.parseInt("5"); String str = Integer.toString(val);The toString() method above represents a value in string and formats.
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
368 Views
Every Java primitive data type has a class dedicated to it. These classes wrap the primitive data type into an object of that class. Therefore, it is known as wrapper classes.The following is the program that displays a Primitive DataType in a Wrapper Object.Example Live Demopublic class Demo { public static void main(String[] args) { Boolean myBoolean = new Boolean(true); boolean val1 = myBoolean.booleanValue(); System.out.println(val1); Character myChar = new Character('a'); char val2 = myChar.charValue(); System.out.println(val2); Short myShort ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
184 Views
Underflow occurs when the given value is less than the maximum prescribed size of a data type. The underflow condition can result to an error or now the implementation of the programming language handles it on its own.To display underflow of datatypes, I have taken an example of double datatype. Double data type is a single-precision 64-bit IEEE 754 floating point.The following program display underflow of datatype in Java.Example Live Demopublic class Demo { public static void main(String[] args) { System.out.println("Displaying Underflow... "); double val1 = 3.2187E-320; System.out.println(val1/1000000); } }OutputDisplaying ... Read More