
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 9150 Articles for Object Oriented Programming

196 Views
In this article, we'll learn how to check whether the entered value is ASCII 7-bit alphabetic lowercase in Java. In ASCII, the lowercase alphabets begin with the character ‘a’ and end with ‘z’. We will write a program checking whether a character is a lowercase alphabetic character using a simple if-else statement. Problem Statement We are given a character, and we need to create a Java program that checks whether the character is a lowercase letter in the ASCII 7-bit range, meaning it falls between 'a' and 'z'. We will also check if the character is uppercase, meaning ... Read More

763 Views
To compare two objects of Character type in Java, use the compareTo() method.Firstly, we have created two Character type.Character one = new Character('m'); Character two = new Character('k');Now, to compare them, we have used the compareTo() method.int res = one.compareTo(two);The following is the example that compares character objects.Example Live Demopublic class Demo { public static void main(String []args) { Character one = new Character('m'); Character two = new Character('k'); System.out.println("Character object 1: "+one); System.out.println("Character object 2: "+two); int res = one.compareTo(two); if ... Read More

2K+ Views
A prime number is a number that is only divisible by one or itself. Some of the prime numbers are 2, 3, 5, 7, 11, 13 etc.Some of the different methods to find a prime number in Java are given as follows −Method 1 - Find if a number is prime without using a functionA program that finds if the given number is prime without using a function is given as follow −Example Live Demopublic class Example { public static void main(String args[]) { int num = 11, flag=0; if(num == 0||num == 1) { System.out.println( num + " is not a prime number"); } else { for(int i = 2; i

6K+ Views
Permutation and Combination are a part of Combinatorics. Permutation is the different arrangements that a set of elements can make if the elements are taken one at a time, some at a time or all at a time. Combination is is the different ways of selecting elements if the elements are taken one at a time, some at a time or all at a time.An example of this is given as follows −Permutation = factorial(n) / factorial(n-r); Combination = factorial(n) / (factorial(r) * factorial(n-r)); n = 5 r = 3 Permutation = 60 Combination = 10A program that demonstrates this ... Read More

2K+ Views
A stack class is provided by the Java collection framework and it implements the Stack data structure. The stack implements LIFO i.e. Last In First Out. This means that the elements pushed last are the ones that are popped first.The following are some of the methods.Sr.NoMethods & Description1boolean empty()Tests if this stack is empty. Returns true if the stack is empty, and returns false if the stack contains elements.2Object peek( )Returns the element on the top of the stack, but does not remove it.3Object pop( )Returns the element on the top of the stack, removing it in the process.4Object push(Object ... Read More

4K+ Views
A set in Java is modelled after the mathematical set and it cannot contain duplicate elements. The set interface contains the methods that are inherited from Collection. The method remove() removes the specified items from the set collection. A program that demonstrates the removal of items from Set using remove() is given as follows − Problem Statement Given a Set, write a Java program to remove the elements from the Set − Input [115, 20, 5, 70, 89, 10, 30, 111] Output [115, 20, 5, 70, 10, 30, 111] ... Read More

3K+ Views
For converting a primitive type value to a string in Java, use the valueOf() method.Let’s say we want to convert the following double primitive to string.double val4 = 8.34D;For that, use the valueOf() method. It converts it into a string.String str4 = String.valueOf(val4);Example Live Demopublic class Demo { public static void main(String[] args) { int val1 = 5; char val2 = 'z'; float val3 = 9.56F; double val4 = 8.34D; System.out.println("Integer: "+val1); System.out.println("Character: "+val2); System.out.println("Float: "+val3); ... Read More

827 Views
The valueOf() method is used in Java to convert char array to string.Here is our char array.// char array char[] c = {'p','q','r','s','t','u','v'};To convert it to string, use the valueOf() method.String str = String.valueOf(c);Example Live Demopublic class Demo { public static void main(String[] args) { // char array char[] c = {'p','q','r','s','t','u','v'}; // converting to string String str = String.valueOf(c); System.out.println("String: "+str); } }OutputString: pqrstuv

5K+ Views
The valueOf() method is used in Java to convert short to string.Let’s say we have the following short value.short val = 20;Converting the above short value to string.String.valueOf(val);Example Live Demopublic class Demo { public static void main(String[] args) { short shortVal = 55; // converting short to String String str = String.valueOf(shortVal); System.out.println("String: "+str); } }OutputString: 55

299 Views
The valueOf() method is used in Java to convert float to string.Let’s say we have the following float value.float val = 10.18465F;Converting the above float value to string.String.valueOf(val);Example Live Demopublic class Demo { public static void main(String[] args) { float val = 98.18465F; // converting float to String String str = String.valueOf(val); System.out.println("String: "+str); } }OutputString: 98.18465