Karthikeya Boyini has Published 2383 Articles

Java Program to check whether the entered value is ASCII 7-bit control character

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:13:37

219 Views

To check whether the entered value is ASCII 7-bit control character, check the characters ASCII value before 32 and 127. These are the control characters.Here, we have a character.char one = ' n ';Now, we have checked a condition with if-else to check for character less than 32 (ASCII) and ... Read More

Java Program to add long integers and check for overflow

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:10:16

579 Views

To check for Long overflow, we need to check the Long.MAX_VALUE with the added long result. Here, Long.MAX_VALUE is the maximum value of Long type in Java.Let us see an example wherein long integers are added and if the result is more than the Long.MAX_VALUE, then an exception is thrown.The ... Read More

Java program to remove items from Set

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:09:04

2K+ 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 ... Read More

Permutation and Combination in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 07:04:26

4K+ 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 ... Read More

Compare two objects of Character type in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 06:59:37

441 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 ... Read More

Convert Char array to String in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 06:24:54

586 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) ... Read More

Time Functions in Java

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 06:19:02

679 Views

Java provides the Date class available in java.util package, this class encapsulates the current date and time. The time functions can be accessed from the java.util.Date class. This represents an instance of time with millisecond precision.One of the time function in Java is the getTime() function. It returns the number ... Read More

Java program to display Astrological sign or Zodiac sign for given date of birth

karthikeya Boyini

karthikeya Boyini

Updated on 26-Jun-2020 05:42:05

6K+ Views

Each date of birth corresponds to a given Zodiac sign. A table that demonstrates these signs and their corresponding dates is given below −Zodiac SignDateAriesMarch 21 - April 19TaurusApril 20 - May 20GeminiMay 21 - June 20CancerJune 21 - July 22LeoJuly 23 - August 22VirgoAugust 23 - September 22LibraSeptember 23 ... Read More

Java program to check if a Substring is present in a given String

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 14:23:59

946 Views

A substring is a part of a string and it can be checked if a particular substring is present in the given string or not. An example of this is given as follows −String = The sunset is beautiful Substring = sunsetThis substring is present in the string.A program that ... Read More

Reverse words in a given String in Java

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 14:16:25

4K+ Views

The order of the words in a string can be reversed and the string displayed with the words in reverse order. An example of this is given as follows.String = I love mangoes Reversed string = mangoes love IA program that demonstrates this is given as follows.Example Live Demoimport java.util.regex.Pattern; public ... Read More

Advertisements