• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Explain instanceof if-statement

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class Smooth
class Silky extends Smooth{
int y =5;
int x = 7;
public static main(String...args){
new Silky().go();
}
void go(){

if(x > y &(Boolean)(this instaceof Silky))
System.out.print("a");
if(Long.valueOf()instanceof Number)
System.out.print("b");

}
}


Question: Please explain the if-statement
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly do you want to know; what the instanceof keyword means? With instanceof, you can check if an object is an instance of a particular class or interface.

By the way, the cast to Boolean in the if-statement is strange and unnecessary, and also the use of '&' instead of '&&' is strange.
reply
    Bookmark Topic Watch Topic
  • New Topic