Author:
Daisy Williams
Feb
8
Static import is a new feature introduced in j2SE 5.0. It allows the static members of the imported class to be treated as if they were declared in the class that uses them. It is now no longer required to use the static class name and dot operator as was required before. Static imports are of the following two types:
- One in which all the members of a particular static class are imported:
import static packageName.ClassName.*;
- And the other in which only a particular member of a class is imported:
import static packageName.ClassName.membername;
Permanent link to this post (94 words, estimated 23 secs reading time)
Author:
Daisy Williams
Nov
12
class Ques{
public static void main (String[] argv){
int p1 = 0102;
int p2 = -10;
int mod = p1 % p2;
System.out.println(”mod = ” +mod);
}
}
Permanent link to this post (29 words, estimated 7 secs reading time)
Author:
Daisy Williams
Aug
29
The instanceof operator is a binary operator that determines at runtime whether its left operand is an instance of its right operand.
Syntax:
obj instanceof type
where, obj (the left operand) must be an instance of a class and type (the right operand) may be a class, interface, or an array type. The instanceof operator evaluates to true if the left operand is of the specified type or can be cast to the specified type. Otherwise, it evaluates to false. The instanceof operator cannot be used with primitive data types.