Grep command with e option45 comments
How beginners can make money online with binary trading
Every expression written in the Java programming language has a type that can be deduced from the structure of the expression and the types of the literals, variables, and methods mentioned in the expression.
It is possible, however, to write an expression in a context where the type of the expression is not appropriate. In some cases, this leads to an error at compile time. In other cases, the context may be able to accept a type that is related to the type of the expression; as a convenience, rather than requiring the programmer to indicate a type conversion explicitly, the Java programming language performs an implicit conversion from the type of the expression to a type acceptable for its surrounding context.
A specific conversion from type S to type T allows an expression of type S to be treated at compile time as if it had type T instead. In some cases this will require a corresponding action at run time to check the validity of the conversion or to translate the run-time value of the expression into a form appropriate for the new type T.
A conversion from type Object to type Thread requires a run-time check to make sure that the run-time value is actually an instance of class Thread or one of its subclasses; if it is not, an exception is thrown. A conversion from type Thread to type Object requires no run-time action; Thread is a subclass of Object , so any reference produced by an expression of type Thread is a valid reference value of type Object.
A conversion from type int to type long requires run-time sign-extension of a bit integer value to the bit long representation. No information is lost. A conversion from type double to type long requires a nontrivial translation from a bit floating-point value to the bit integer representation. Depending on the actual run-time value, information may be lost. In every conversion context, only certain specific conversions are permitted.
For convenience of description, the specific conversions that are possible in the Java programming language are grouped into several broad categories:. There are five conversion contexts in which conversion of expressions may occur.
Each context allows conversions in some of the categories named above but not others. The term "conversion" is also used to describe the process of choosing a specific conversion for such a context. For example, we say that an expression that is an actual argument in a method invocation is subject to "method invocation conversion," meaning that a specific conversion will be implicitly chosen for that expression according to the rules for the method invocation argument context.
The conversion process for such operands is called numeric promotion. Promotion is special in that, in the case of binary operators, the conversion chosen for one operand may depend in part on the type of the other operand expression. Then the five conversion contexts are described:. It is more inclusive than assignment or method invocation conversion, allowing any specific conversion other than a string conversion, but certain casts to a reference type may cause an exception at run time.
Specific type conversions in the Java programming language are divided into 13 categories. A conversion from a type to that same type is permitted for any type. This may seem trivial, but it has two practical consequences. First, it is always permitted for an expression to have the desired type to begin with, thus allowing the simply stated rule that every expression is subject to conversion, if only a trivial identity conversion.
Second, it implies that it is permitted for a program to include redundant cast operators for the sake of clarity. A widening primitive conversion does not lose information about the overall magnitude of a numeric value.
A widening primitive conversion from float to double that is not strictfp may lose information about the overall magnitude of the converted value. A widening conversion of an int or a long value to float , or of a long value to double , may result in loss of precision - that is, the result may lose some of the least significant bits of the value.
A widening conversion of a signed integer value to an integral type T simply sign-extends the two's-complement representation of the integer value to fill the wider format. A widening conversion of a char to an integral type T zero-extends the representation of the char value to fill the wider format. A narrowing primitive conversion may lose information about the overall magnitude of a numeric value and may also lose precision and range.
This conversion can lose precision, but also lose range, resulting in a float zero from a nonzero double and a float infinity from a finite double. A double NaN is converted to a float NaN and a double infinity is converted to the same-signed float infinity.
A narrowing conversion of a signed integer to an integral type T simply discards all but the n lowest order bits, where n is the number of bits used to represent type T. In addition to a possible loss of information about the magnitude of the numeric value, this may cause the sign of the resulting value to differ from the sign of the input value. A narrowing conversion of a char to an integral type T likewise simply discards all but the n lowest order bits, where n is the number of bits used to represent type T.
In addition to a possible loss of information about the magnitude of the numeric value, this may cause the resulting value to be a negative number, even though chars represent bit unsigned integer values. A narrowing conversion of a floating-point number to an integral type T takes two steps:. In the first step, the floating-point number is converted either to a long , if T is long , or to an int , if T is byte , short , char , or int , as follows:. Then there are two cases:.
If T is long , and this integer value can be represented as a long , then the result of the first step is the long value V. Otherwise, if this integer value can be represented as an int , then the result of the first step is the int value V. Otherwise, one of the following two cases must be true:. The value must be too small a negative value of large magnitude or negative infinity , and the result of the first step is the smallest representable value of type int or long.
The value must be too large a positive value of large magnitude or positive infinity , and the result of the first step is the largest representable value of type int or long. In the second step:. If T is int or long , the result of the conversion is the result of the first step. The results for char , int , and long are unsurprising, producing the minimum and maximum representable values of the type.
The results for byte and short lose information about the sign and magnitude of the numeric values and also lose precision. The results can be understood by examining the low order bits of the minimum and maximum int. The minimum int is, in hexadecimal, 0x , and the maximum int is 0x7fffffff.
Narrowing Primitive Conversions that lose information. The following conversion combines both widening and narrowing primitive conversions:. Widening reference conversions never require a special action at run time and therefore never throw an exception at run time. They consist simply in regarding a reference as having some other type in a manner that can be proved correct at compile time. Six kinds of conversions are called the narrowing reference conversions:.
From any class type C to any non-parameterized interface type K , provided that C is not final and does not implement K. From any interface type J to any non-parameterized class type C that is not final. From any interface type J to any non-parameterized interface type K , provided that J is not a subinterface of K. From the interface types Cloneable and java. Serializable to any array type T .
Such conversions require a test at run time to find out whether the actual reference value is a legitimate value of the new type. If not, then a ClassCastException is thrown. Boxing conversion converts expressions of primitive type to corresponding expressions of reference type.
Specifically, the following nine conversions are called the boxing conversions:. From type boolean to type Boolean. From type byte to type Byte. From type short to type Short. From type char to type Character. From type int to type Integer. From type long to type Long. From type float to type Float. From type double to type Double. From the null type to the null type. At run time, boxing conversion proceeds as follows:. If p is a value of type boolean , then boxing conversion converts p into a reference r of class and type Boolean , such that r.
If p is a value of type byte , then boxing conversion converts p into a reference r of class and type Byte , such that r. If p is a value of type char , then boxing conversion converts p into a reference r of class and type Character , such that r.
If p is a value of type short , then boxing conversion converts p into a reference r of class and type Short , such that r.
If p is a value of type int , then boxing conversion converts p into a reference r of class and type Integer , such that r. If p is a value of type long , then boxing conversion converts p into a reference r of class and type Long , such that r.
If p is a value of type float then:. If p is not NaN, then boxing conversion converts p into a reference r of class and type Float , such that r. Otherwise, boxing conversion converts p into a reference r of class and type Float such that r. If p is a value of type double , then:. If p is not NaN, boxing conversion converts p into a reference r of class and type Double , such that r. Otherwise, boxing conversion converts p into a reference r of class and type Double such that r.
Ideally, boxing a given primitive value p , would always yield an identical reference. In practice, this may not be feasible using existing implementation techniques.
The rules above are a pragmatic compromise. The final clause above requires that certain common values always be boxed into indistinguishable objects. The implementation may cache these, lazily or eagerly. For other values, this formulation disallows any assumptions about the identity of the boxed values on the programmer's part.
This would allow but not require sharing of some or all of these references. This ensures that in most common cases, the behavior will be the desired one, without imposing an undue performance penalty, especially on small devices. A boxing conversion may result in an OutOfMemoryError if a new instance of one of the wrapper classes Boolean , Byte , Character , Short , Integer , Long , Float , or Double needs to be allocated and insufficient storage is available.
Unboxing conversion converts expressions of reference type to corresponding expressions of primitive type.