Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java instance of a class

// instanceof can be used to check whether an object
// is an instance of a given class or not, as illustrated below
public class Main {
	public static void main(String[] args) {
		String str = new String("Foo");
		System.out.println( str instanceof String); // true
		Shape s = new Triangle();
      	// s is instance of parent class Shape
		System.out.println(s instanceof Shape); // true
      	// s is also instance of child class called Triangle
		System.out.println(s instanceof Triangle); // true

	}
}
class Shape {
	public void draw() {
		System.out.println("Shape draw.");
	}
}
class Triangle extends Shape {
	public void draw() {
		System.out.println("Triangle draw.");
	}
}
Comment

create instance object java

myCar = new Car();
Comment

create new instance of class java

class_name object_name = new class_name();
Comment

PREVIOUS NEXT
Code Example
Java :: timer tick java 
Java :: entry constructor java 
Java :: Java lAccess TreeMap Elements 
Java :: java active displays 
Java :: java coding standards for interfaces 
Java :: Meeting time: Merging Ranges (return) 
Java :: how to print an array in TImber android 
Java :: how to add new nod in dynamic treeview using javascipt 
Java :: Bad JNI version returned from JNI_OnLoad in 
Java :: URI/BEE problem no-1101 solution in Java 
Java :: force orientation programmatically android 
Java :: how to romve a element from arraylist in java 
Java :: mock ioexception mockito on BufferedReader 
Java :: how to put all words from a file in an array java 
Java :: java union of sets 
Java :: how to make a ordering system in microsoft visual basic 2010 express console application 
Java :: leerzeichen ersetzen java 
Java :: get all colors in string spigot 
Java :: output 
Java :: how to clear scoreboard with offline players java 
Java :: validate data type in request body spring validation 
Java :: quitar letras repetidas de una palabra en java 
Java :: tests offline cypress 
Java :: java formatted string input 
Java :: null pointer exception during registering user to the firebase 
Java :: Java Multi-catch block 
Java :: Bukkit dev paid account 
Java :: java 001 
Java :: maximise the rides with the given tokens java 
Java :: Java Super Power java 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =