Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

what is instance of objects in java

MatthewXia
MatthewXia

pls help. im struggling. :(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(:(

2 years ago

Voters

Comments

TopNew
2
CodeLongAndPros
CodeLongAndPros

An instance is something you can use. If you are in your house, your Samsung is an instance of a Tele-Vision. Your iPhone 6S is an instance of a smart-phone. ‘instanceof’ tells you what the instance came from.

For example (this will not work)

INSTANCEOF Samsung yields TV INSTANCEOF iPhone yields phone
2 years ago
1
MatthewXia
MatthewXia

@CodeLongAndPros
ty so much :)

2 years ago
2
Coder100
Coder100

instanceof is just to see if an object is created by a class:

class Something { private final int name; Something (int name) { this.name = name; } } class Something2 { private final int name; Something (int name) { this.name = name; } } Something something = new Something(2); Something2 something2 = new Something2(3); something instanceof Something; // true something2 instanceof Something; // false
2 years ago
1
Coder100
Coder100

whats your question?

2 years ago
1
MatthewXia
MatthewXia

@Coder100
my question is whats a class

2 years ago
1
MatthewXia
MatthewXia

@Coder100
sry i suck at coding

2 years ago
Load more