Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how keuwords like int, char, assert is accessable?

 
Sampathkumar NK
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

how java classes can work with the keywords like int, char, long etc? is it not voilation of OOPS? and where assert() is declared in the j2se package?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, glad you could join us.

Unfortunately this isn't a Servlets question. We have forums specific to APIs, tools, Certifications etc. This way you can go to the direct forum and get the best answer possible from the experts in those arenas.

I am going to move this to the Java In General (Beginner) forum, there should be a link near the top left of this thread that will take you to that forum.

Good Luck

Mark
 
sander hautvast
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
primitives are implemented as classes.
try: Class x=int.class;
and you get a Class object
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Primitive are most certainly not implemented as classes. There are Class objects available which represent the types "int", "char", "byte", etc, but an int is not an instance of that class; the special Class object is just used as a placeholder.

To answer Sampathkumar's question:

First, Welcome to JavaRanch!

Second: ints and chars aren't objects, and Java simply isn't a "pure O-O" language. There aren't many languages that are "pure" in this sense: Smalltalk, Ruby, and Eiffel are perhaps the best known ones. But Java and its cousin C++ are "multiparadigm" languages.

Is this a "violation" of anything? No, of course not, because there's no law that says a languge has to be "pure O-O" (or pure anything.)

Finally, about assert: it's a language keyword introduced in JDK version 1.4. It's not anywhere in the API, as it's not a method: it's described in an article that comes with the JDK 1.4 documentation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic