This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes how keuwords like int, char, assert is accessable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how keuwords like int, char, assert is accessable?" Watch "how keuwords like int, char, assert is accessable?" New topic

how keuwords like int, char, assert is accessable?

Sampathkumar NK

Joined: Jun 24, 2004
Posts: 1

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

Joined: Feb 05, 2001
Posts: 17276

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


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
sander hautvast
Ranch Hand

Joined: Oct 18, 2002
Posts: 71
primitives are implemented as classes.
try: Class x=int.class;
and you get a Class object
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

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.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: how keuwords like int, char, assert is accessable?
It's not a secret anymore!