As in Java, everything is class. Is there a java file present for new keyword also? If yes, please tell the package name.
Asked
Active
Viewed 96 times
-8
-
1http://stackoverflow.com/questions/7019754/what-does-the-new-keyword-actually-do-in-java-and-should-i-avoid-creating-new – Tano Sep 19 '16 at 05:29
-
1It's an *operator*. Do you also think you can find the `+` operator in a class? – Andreas Sep 19 '16 at 05:29
-
No, idea about that '+' operator but i am talking about new operator. – Nick Silicon Sep 19 '16 at 05:32
1 Answers
6
As in Java, everything is class.
No, not necessarily.
Is there a java file present for new keyword also?
No there isn't. Keywords and operators aren't classes, they are reserved words or symbols that are used in the language. They aren't objects.
new
is an operator and keyword. There's no class for keywords such as return
, public
, etc. and no classes for the +
operator either.
As for primitive wrapper classes such as: Float, Double, Long, Boolean, Character, Byte, Short, Integer
, they are class forms of primitives that have more capabilities than their respective primitives and can be used in things like data structures, but this is only applicable for primitives. new
is not a primitive.

Andrew Li
- 55,805
- 14
- 125
- 143
-
Keyword like float, byte are having .java file files inside java/lang folder. – Nick Silicon Sep 19 '16 at 05:33
-
Wrapper classes are also type of classes which can be defined in java. So, there must be some code which defines the working of new operator? – Nick Silicon Sep 19 '16 at 05:37
-
No their isn't. @NickSilicon, wrapper classes are for *primitives*. `new` is not a primitive. `new` is a reserved keyword that has functions at the lower level, such as assembly where memory is allocated for a new 'object'. – Andrew Li Sep 19 '16 at 05:38
-
Do all new operator in all programming language work in same exact way? – Nick Silicon Sep 19 '16 at 05:41
-
@NickSilicon Not sure what you mean by the exact same way. `new` in Java means a new object is created by allocating memory. It has the same concept in many languages, but say in Python, `new` is completely omitted when it comes to instantiation. – Andrew Li Sep 19 '16 at 05:43
-
As you said new functions at assembly level so it means new functions in same way for all the programming language as assembly language is machine dependent. – Nick Silicon Sep 19 '16 at 05:45
-
@NickSilicon Not necessarily *exactly* the same but have much of the same functionality. – Andrew Li Sep 19 '16 at 05:46
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/123662/discussion-between-nick-silicon-and-andrew-l). – Nick Silicon Sep 19 '16 at 05:47