Showing posts with label Constant Value. Show all posts
Showing posts with label Constant Value. Show all posts

FileInputStream class methods in Java

java.io.FileInputStream

A FileInputStream obtains input bytes from a file in a file system. What files are available depends on the host environment.

FileInputStream is meant for reading streams of raw bytes such as image data.

Some methods of FileInputStream class

available(): This method returns an estimate of the number of remaining bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.

close(): This method closes this file input stream and releases any system resources associated with the stream.

getChannel(): This method returns the unique FileChannel object associated with this file input stream.

getFD(): This method returns the FileDescriptor object that represents the connection to the actual file in the file system being used by this FileInputStream.

read(): This method reads a byte of data from this input stream. This method blocks if no input is yet available.

read(byte[]): This method reads up to b.length bytes of data from this input stream into an array of bytes.

read(byte[], int, int): This method reads up to len bytes of data from this input stream into an array of bytes.

skip(long): This method skips over and discards n bytes of data from the input stream.


Some constants of BigDecimal in Java

Some of the constants of BigDecimal Class.

1. BigDecimal.ONE: 

Syntax:

BigDecimal java.math.BigDecimal.ONE

The value 1, with a scale of 0.

Approach

Java

import java.math.BigDecimal;

public class BigDecimalONE {
    public static void main(String[] args) {

        System.out.println(BigDecimal.ONE);
    }
}

Output:

1


2. BigDecimal.TEN:

Syntax:

BigDecimal java.math.BigDecimal.TEN

The value is 10, with a scale of 0.

Approach

Java

import java.math.BigDecimal;

public class BigDecimalTEN {
    public static void main(String[] args) {

        System.out.println(BigDecimal.TEN);
    }
}

Output:

10


3. BigDecimal.ZERO:

Syntax:

BigDecimal java.math.BigDecimal.ZERO

The value 0, with a scale of 0.

Approach

Java

import java.math.BigDecimal;

public class BigDecimalZERO {
    public static void main(String[] args) {

        System.out.println(BigDecimal.ZERO);
    }
}

Output:

0


Some other methods of BigDecimal

BigDecimal.abs(): This method returns a BigDecimal whose value is the absolute value of this BigDecimal, and whose scale is this.scale().

BigDecimal.abs(MathContext): This method returns a BigDecimal whose value is the absolute value of this BigDecimal, with rounding according to the context settings.

BigDecimal.add(BigDecimal):  This method returns a BigDecimal whose value is (this +augend).

BigDecimal.add(BigDecimal, MathContext): This method returns a BigDecimal whose value is (this + augend), with rounding according to the context settings.

byteValue(): This method returns the value of the specified number as a byte.

BigDecimal.byteValueExact(): This method converts this BigDecimal to a byte, checking for lost information.

compareTo(): This method compares this BigDecimal with the specified BigDecimal.

divide(BigDecimal): This method returns a BigDecimal whose value is (this /divisor).

divide(BigDecimal, MathContext): This method returns a BigDecimal whose value is (this /divisor), with rounding according to the context settings.

divide(BigDecimal, RoundingMode): This method returns a BigDecimal whose value is (this /divisor), and whose scale is this.scale().

divide(BigDecimal, int, RoundingMode): This method returns a BigDecimal whose value is (this /divisor), and whose scale is as specified.

divideAndRemainder(BigDecimal): This method returns a two-element BigDecimal array containing the result of divideToIntegralValue followed by the result of the remainder on the two operands.

divideAndRemainder(BigDecimal, MathContext): This method returns a two-element BigDecimal array containing the result of divideToIntegralValue followed by the result of the remainder on the two operands calculated with rounding according to the context settings.

divideToIntegralValue(BigDecimal): This method returns a BigDecimal whose value is the integer part of the quotient (this / divisor) rounded down.

divideToIntegralValue(BigDecimal ,MathContext): This method returns a BigDecimal whose value is the integer part of (this / divisor).

doubleValue(): This method converts this BigDecimal to a double.

equals(Object): This method compares this BigDecimal with the specified Object for equality.

floatValue(): This method converts this BigDecimal to a float.

hashCode(): This method returns the hash code for this BigDecimal.

intValue(): This method converts this BigDecimal to an int.

intValueExact(): It converts this BigDecimal to an int, checking for lost information.

longValue(): It converts this BigDecimal to a long.

longValueExact(): It converts this BigDecimal to a long, checking for lost information.

max():  It returns the maximum of this BigDecimal and val.

min(): It returns the minimum of this BigDecimal and val.

movePointLeft(): It returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left.

movePointRight(): It returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the right.

multiply(BigDecimal): It returns a BigDecimal whose value is (this ×multiplicand), and whose scale is (this.scale() +multiplicand.scale()).

multiply(BigDecimal, MathContext): It returns a BigDecimal whose value is (this ×multiplicand), with rounding according to the context settings.

negate(): It returns a BigDecimal whose value is (-this),and whose scale is this.scale().

negate(MathContext): It returns a BigDecimal whose value is (-this), with rounding according to the context settings.

plus(): It returns a BigDecimal whose value is (+this), and whose scale is this.scale().

plus(MathContext): It returns a BigDecimal whose value is (+this), with rounding according to the context settings.

pow(int): It returns a BigDecimal whose value is (this^n), The power is computed exactly, to unlimited precision.

pow(int, MathContext): It returns a BigDecimal whose value is (this%^n).

precision(): It returns the precision of this BigDecimal.

remainder(BigDecimal): It returns a BigDecimal whose value is (this % divisor).

remainder(BigDecimal, MathContext): It returns a BigDecimal whose value is (this %divisor), with rounding according to the context settings.

round(MathContext): It returns a BigDecimal rounded according to the MathContext settings. 

scale(): It returns the scale of this BigDecimal.

scaleByPowerOfTen(int):  It returns a BigDecimal whose numerical value is equal to(this * 10^n).

setScale(int): It returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to this BigDecimal's.

setScale(int, RoundingMode): It returns a BigDecimal whose scale is the specified value, and whose unscaled value is determined by multiplying or dividing this BigDecimal's unscaled value by the appropriate power of ten to maintain its overall value.

shortValue(): It returns the value of the specified number as a short.

shortValueExact(): It converts this BigDecimal to a short, checking for lost information.

signum(): It returns the signum function of this BigDecimal.

sqrt(MathContext): It returns an approximation to the square root of this with rounding according to the context settings.

stripTrailingZeros(): It returns a BigDecimal which is numerically equal to this one but with any trailing zeros removed from the representation

subtract(BigDecimal):  It returns a BigDecimal whose value is (this -subtrahend), and whose scale is max(this.scale(),subtrahend.scale()).

subtract(BigDecimal, MathContext): It returns a BigDecimal whose value is (this - subtrahend), with rounding according to the context settings.

Some constants of BigDecimal: Some constants of BigDecimal, BigDecimal.ONE, BigDecimal.ZERO and BigDecimal.TEN

toBigInteger(): It converts this BigDecimal to a BigInteger.

toBigIntegerExact(): It converts this BigDecimal to a BigInteger, checking for lost information. An exception is thrown if this BigDecimal has a nonzero fractional part.

toEngineeringString(): It returns a string representation of this BigDecimal, using engineering notation if an exponent is needed.

toPlainString(): It returns a string representation of this BigDecimal without an exponent field.

toString(): It returns the string representation of this BigDecimal, using scientific notation if an exponent is needed.

ulp(): It returns the size of an ulp, a unit in the last place, of this BigDecimal.

unscaledValue(): It returns a BigInteger whose value is the unscaled value of this BigDecimal. (Computes (this *10^this.scale()).)

BigDecimal.valueOf(long, int): It translates a long unscaled value and an int scale into a BigDecimal.

BigDecimal.valueOf(double): It translates a double into a BigDecimal, using the double's canonical string representation.

BigDecimal.valueOf(long): It translates a long value into a BigDecimalwith a scale of zero.

Some constants of StrictMath class in Java

Some of the constants of StrictMath class.

1. StrictMath.E

Syntax:

double java.lang.StrictMath.E: 2.718281828459045

The double value that is closer than any other to e, the base of the natural logarithms.

Approach

Java

public class StrictMathE {
    public static void main(String[] args) {

        System.out.println(StrictMath.E);
    }
}

Output:

2.718281828459045


2. StrictMath.PI

Syntax:

double java.lang.StrictMath.PI: 3.141592653589793

The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

Approach

Java

public class StrictMathPI {
    public static void main(String[] args) {

        System.out.println(StrictMath.PI);
    }
}

Output:

3.141592653589793


Constants of Short class in Java

Some of the constants of Short class.

1. Short.BYTES

Syntax:

int java.lang.Short.BYTES: 2

The number of bytes is used to represent a short value in two'scomplement binary form. 

Approach

Java

public class ShortBYTES {
    public static void main(String[] args) {

        System.out.println(Short.BYTES);
    }
}

Output:

2


2. Short.MAX_VALUE

Syntax:

short java.lang.Short.MAX_VALUE: 32767

A constant holding the maximum value a short can have, 2^15-1.

Approach

Java

public class ShortMAX_VALUE {
    public static void main(String[] args) {

        System.out.println(Short.MAX_VALUE);
    }
}

Output:

32767


3. Short.MIN_VALUE

Syntax:

short java.lang.Short.MIN_VALUE: -32768

A constant holding the minimum value a short can have, -2^15.

Approach

Java

public class ShortMIN_VALUE {
    public static void main(String[] args) {

        System.out.println(Short.MIN_VALUE);
    }
}

Output:

-32768


4. Short.SIZE

Syntax:

int java.lang.Short.SIZE: 16

The number of bits used to represent a short value in two'scomplement binary form.

Approach

Java

public class ShortSIZE {
    public static void main(String[] args) {

        System.out.println(Short.SIZE);
    }
}

Output:

16

Character.UnicodeBlock constants Part -I

Some of the constants of Character.UnicodeBlock.

1. Character.UnicodeBlock.ADLAM

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ADLAM

Constant for the "Adlam" Unicode character block.

2. Character.UnicodeBlock.AEGEAN_NUMBERS

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.AEGEAN_NUMBERS

Constant for the "Aegean Numbers" Unicode character block.

3. Character.UnicodeBlock.AHOM

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.AHOM

Constant for the "Ahom" Unicode character block.

4. Character.UnicodeBlock.ALCHEMICAL_SYMBOLS

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ALCHEMICAL_SYMBOLS

Constant for the "Alchemical Symbols" Unicode character block.

5. Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS

Constant for the "Alphabetic Presentation Forms" Unicode character block.


Approach

Java

public class CharacterUnicodeBlockConstants1 {
    public static void main(String[] args) {

        System.out.println(Character.UnicodeBlock.ADLAM);

        System.out.println(Character.UnicodeBlock.AEGEAN_NUMBERS);

        System.out.println(Character.UnicodeBlock.AHOM);

        System.out.println(Character.UnicodeBlock.ALCHEMICAL_SYMBOLS);

        System.out.println(Character.UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS);

    }
}


Output:

ADLAM AEGEAN_NUMBERS AHOM ALCHEMICAL_SYMBOLS ALPHABETIC_PRESENTATION_FORMS


6. Character.UnicodeBlock.ANATOLIAN_HIEROGLYPHS

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ANATOLIAN_HIEROGLYPHS

Constant for the "Anatolian Hieroglyphs" Unicode character block.

7. Character.UnicodeBlock.ANCIENT_GREEK_MUSICAL_NOTATION

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ANCIENT_GREEK_MUSICAL_NOTATION

Constant for the "Ancient Greek Musical Notation" Unicode character block.

8. Character.UnicodeBlock.ANCIENT_GREEK_NUMBERS

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ANCIENT_GREEK_NUMBERS

Constant for the "Ancient Greek Numbers" Unicode character block.

9. Character.UnicodeBlock.ANCIENT_SYMBOLS

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ANCIENT_SYMBOLS

Constant for the "Ancient Symbols" Unicode character block.

10. Character.UnicodeBlock.ARABIC

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ARABIC

Constant for the "Arabic" Unicode character block.


Approach

Java

public class CharacterUnicodeBlockConstants1 {
    public static void main(String[] args) {

        System.out.println(Character.UnicodeBlock.ANATOLIAN_HIEROGLYPHS);

        System.out.println(Character.UnicodeBlock.ANCIENT_GREEK_MUSICAL_NOTATION);

        System.out.println(Character.UnicodeBlock.ANCIENT_GREEK_NUMBERS);

        System.out.println(Character.UnicodeBlock.ANCIENT_SYMBOLS);

        System.out.println(Character.UnicodeBlock.ARABIC);


    }
}


Output:

ANATOLIAN_HIEROGLYPHS ANCIENT_GREEK_MUSICAL_NOTATION ANCIENT_GREEK_NUMBERS ANCIENT_SYMBOLS ARABIC


11. Character.UnicodeBlock.ARABIC_EXTENDED_A

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ARABIC_EXTENDED_A

Constant for the "Arabic Extended-A" Unicode character block.

12. Character.UnicodeBlock.ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOL

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS

Constant for the "Arabic Mathematical Alphabetic Symbols" Unicodecharacter

13. Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A

Syntax:

UnicodeBlock  java.lang.Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A

Constant for the "Arabic Presentation Forms-A" Unicode character block.

14. Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B

Constant for the "Arabic Presentation Forms-B" Unicode character block.

15. Character.UnicodeBlock.ARABIC_SUPPLEMENT

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ARABIC_SUPPLEMENT

Constant for the "Arabic Supplement" Unicode character block.


Approach

Java

public class CharacterUnicodeBlockConstants1 {
    public static void main(String[] args) {

        System.out.println(Character.UnicodeBlock.ARABIC_EXTENDED_A);

        System.out.println(Character.UnicodeBlock.ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS);

        System.out.println(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A);

        System.out.println(Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B);

        System.out.println(Character.UnicodeBlock.ARABIC_SUPPLEMENT);


    }
}


Output:

ARABIC_EXTENDED_A ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS ARABIC_PRESENTATION_FORMS_A ARABIC_PRESENTATION_FORMS_B ARABIC_SUPPLEMENT


16. Character.UnicodeBlock.ARMENIAN

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ARMENIAN

Constant for the "Armenian" Unicode character block.

17. Character.UnicodeBlock.ARROWS

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.ARROWS

Constant for the "Arrows" Unicode character block.

18. Character.UnicodeBlock.AVESTAN

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.AVESTAN

Constant for the "Avestan" Unicode character block.

19. Character.UnicodeBlock.BALINESE

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.BALINESE

Constant for the "Balinese" Unicode character block.

20. Character.UnicodeBlock.BAMUM

Syntax:

UnicodeBlock java.lang.Character.UnicodeBlock.BAMUM

Constant for the "Bamum" Unicode character block.


Approach

Java

public class CharacterUnicodeBlockConstants1 {
    public static void main(String[] args) {


        System.out.println(Character.UnicodeBlock.ARMENIAN);

        System.out.println(Character.UnicodeBlock.ARROWS);

        System.out.println(Character.UnicodeBlock.AVESTAN);

        System.out.println(Character.UnicodeBlock.BALINESE);

        System.out.println(Character.UnicodeBlock.BAMUM);

    }
}


Output:

ARMENIAN ARROWS AVESTAN BALINESE BAMUM



Character constants in Java Part -VIII

Some of the constants of the Character class in Java.

1. Character.ENCLOSING_MARK

Syntax:

byte java.lang.Character.ENCLOSING_MARK: 7

General category "Me" in the Unicode specification.

Java

public class CharacterConstants6 {
    public static void main(String[] args) {

        System.out.println(Character.ENCLOSING_MARK);
    }
}

Output:

7


2. Character.END_PUNCTUATION

Syntax:

byte java.lang.Character.END_PUNCTUATION: 22

General category "Pe" in the Unicode specification.

Java

public class CharacterConstants6 {
    public static void main(String[] args) {

        System.out.println(Character.END_PUNCTUATION);

    }
}

Output:

22


3. Character.FINAL_QUOTE_PUNCTUATION

Syntax:

byte java.lang.Character.FINAL_QUOTE_PUNCTUATION: 30

General category "Pf" in the Unicode specification.

Java

public class CharacterConstants6 {
    public static void main(String[] args) {

        System.out.println(Character.FINAL_QUOTE_PUNCTUATION);

    }
}

Output:

30


4. Character.FORMAT

Syntax:

byte java.lang.Character.FORMAT: 16

General category "Cf" in the Unicode specification.

Java

public class CharacterConstants6 {
    public static void main(String[] args) {

    System.out.println(Character.FORMAT);

    }
}

Output:

16


5. Character.INITIAL_QUOTE_PUNCTUATION

Syntax:

byte java.lang.Character.INITIAL_QUOTE_PUNCTUATION: 29

General category "Pi" in the Unicode specification.

Java

public class CharacterConstants6 {
    public static void main(String[] args) {

        System.out.println(Character.INITIAL_QUOTE_PUNCTUATION);
    }
}

Output:

29


6. Character.LETTER_NUMBER

Syntax:

byte java.lang.Character.LETTER_NUMBER: 10

General category "Nl" in the Unicode specification.

Java

public class CharacterConstants6 {
    public static void main(String[] args) {

        System.out.println(Character.LETTER_NUMBER);

    }
}

Output:

10


7. Character.TITLECASE_LETTER

Syntax:

byte java.lang.Character.TITLECASE_LETTER: 3

General category "Lt" in the Unicode specification.

Approach

Java

public class CharacterConstants9 {
    public static void main(String[] args) {

        System.out.println(Character.TITLECASE_LETTER);

    }
}

Output:

3


8. Character.UNASSIGNED

Syntax:

byte java.lang.Character.UNASSIGNED: 0

General category "Cn" in the Unicode specification.

Approach

Java

public class CharacterConstants9 {
    public static void main(String[] args) {

        System.out.println(Character.UNASSIGNED);

    }
}

Output:

0


9. Character.UPPERCASE_LETTER

Syntax:

byte java.lang.Character.UPPERCASE_LETTER: 1

General category "Lu" in the Unicode specification. 

Approach

Java

public class CharacterConstants9 {
    public static void main(String[] args) {

        System.out.println(Character.UPPERCASE_LETTER);

    }
}

Output:

1


Some more constants of Character class:


Character constants Part -I


Character constants Part -II


Character constants Part -III


Character constants Part - IV


Character constants Part -V


Character constants Part -VI


Character constants Part- VII