Minimum and Maximum Values of Primitive Data Types in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:05:50

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

Check if String Contains Only Unicode Letters and Space in Java

Arjun Thakur
Updated on 26-Jun-2020 10:05:37

2K+ Views

In order to check if a String has only unicode letters in Java, we use the isDigit() and charAt() methods with decision making statements.The isLetter(int codePoint) method determines whether the specific character (Unicode codePoint) is a letter. It returns a boolean value, either true or false.Declaration − The java.lang.Character.isLetter() method is declared as follows −public static boolean isLetter(int codePoint)where the parameter codePoint represents the character to be checked.The charAt() method returns a character value at a given index. It belongs to the String class in Java. The index must be between 0 to length()-1.Declaration − The java.lang.String.charAt() method is declared ... Read More

Overflow of Data Types in Java

Samual Sam
Updated on 26-Jun-2020 10:05:01

1K+ 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

Boolean Type in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:04:35

13K+ 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

Parse String to Boolean Object in Java

Samual Sam
Updated on 26-Jun-2020 10:04:00

262 Views

The valueOf() method returns the relevant Number Object holding the value of the argument passed. The argument can be a primitive data type, String, Boolean, etc. Therefore, to parse a string to a Boolean object, use the Java valueOf() method.The following is an example showing how to parse a string to a Boolean object in Java.Example Live Demopublic class Demo {    public static void main(String[] args) {       System.out.println("Parsing a string to a Boolean object...");       Boolean val = Boolean.valueOf("true");       System.out.println("Value: "+val);    } }OutputParsing a string to a Boolean object... Value: trueBoolean ... Read More

Get Floor Value of a Number Using Math.floor() in Java

Ankith Reddy
Updated on 26-Jun-2020 10:03:57

564 Views

To get the floor value of a number, we use the java.lang.Math.floor() method. The Math.floor() method returns the largest (closest to positive infinity) double value which is less than or equal to the parameter and has a value which is equal to a mathematical integer on the number line. If the parameter is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.Declaration - The java.lang.Math.floor() method is declared as follows −public static double floor(double a)Let us see a program to get the floor value of a number in Java.Example Live Demoimport ... Read More

String Representation of Boolean in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:03:36

597 Views

To get the string representation of Boolean, use the toString() method.Firstly, we have used the valueOf() method for Boolean object and set a string value.Boolean val = Boolean.valueOf("false");The same is then represented using “toString() method.val.toString();Let us see the complete example that prints the string representation of Boolean (True and False) in Java.Example Live Demopublic class Demo {    public static void main(String[] args) {       // false       Boolean val = Boolean.valueOf("false");       System.out.println("Displaying the string representation of Boolean");       System.out.println(val.toString());       // true       val = Boolean.valueOf("true");   ... Read More

Get the Maximum of Two Numbers Using Math.max in Java

George John
Updated on 26-Jun-2020 10:03:08

1K+ Views

To obtain the maximum of two numbers using Math.max in Java, we use the java.lang.Math.max() method. The Math.max() accepts two numbers and returns the greater of the two. The result is closer to positive infinity on the number line. Even if one of the values is not a number(NaN), the result is NaN.Declaration - The java.lang.Math.max() method is declared as follows −public static int max(int a, int b) public static double max(double a, double b) public static long max(long a, long b) public static float max(float a, float b)Let us see a program to get the maximum of two numbers ... Read More

Compare Two Boolean Arrays in Java

Samual Sam
Updated on 26-Jun-2020 10:03:06

239 Views

Use Arrays.equals() method to compare two Boolean Arrays. Let us first create some arrays to be compared. For using this method, you need to import the following package −import java.util.Arrays;We have 4 arrays and value “true” and “false” are assigned to them.boolean[] myArr1 = new boolean[] { true, false, true, true, true }; boolean[] myArr2 = new boolean[] { true, false, true, true , true }; boolean[] myArr3 = new boolean[] { false, false, true, true, true }; boolean[] myArr4 = new boolean[] { true, false, false, true , false };Now, let us compare Boolean arrays 1 and 2.Arrays.equals(myArr1, myArr2);In ... Read More

Zip Entry CompressionMethod Function in PHP

karthikeya Boyini
Updated on 26-Jun-2020 10:02:29

58 Views

The zip_entry_compressionmethod() function returns the compression method of a zip archive entry.Syntaxzip_entry_compressionmethod()Parameterszip_entry − The zip entry resource. Required.ReturnThe zip_entry_compressionmethod() function returns the compression method of a zip archive entry.The following is an example. Let’s say we have 3 files in our zip archive "new.txt", therefore the compression method for all of these files will get displayed.ExampleOutputCompression Method = deflated Compression Method = deflated Compression Method = deflated

Advertisements