It's not a secret anymore!*
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 8 in Action this week in the Java 8 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
Author

how keuwords like int, char, assert is accessable?

Sampathkumar NK
Greenhorn

Joined: Jun 24, 2004
Posts: 1
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
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
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

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]
 
wood burning stoves
 
subject: how keuwords like int, char, assert is accessable?
 
Similar Threads
is assert java keyword?
Assert statements
Marcus Exam #1, Q 26
howto test "assert" in eclipse ?
how to initialize char??