aspose file tools*
The moose likes Java in General and the fly likes String literals Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "String literals" Watch "String literals" New topic
Author

String literals

Mukul Anand
Greenhorn

Joined: Nov 28, 2012
Posts: 29
At page no. 63, section 3.10.5,
The Java Language Specification for Java 5/6 states that
Strings computed by constant expressions (§15.28) are computed at compile
time and then treated as if they were literals.

What does the phrase "computed at compile time" mean?
It sounds as if those String objects are created at compile-time, which is funny.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Mukul Anand wrote:At page no. 63, section 3.10.5,
The Java Language Specification for Java 5/6 states that
Strings computed by constant expressions (§15.28) are computed at compile
time and then treated as if they were literals.

What does the phrase "computed at compile time" mean?
It sounds as if those String objects are created at compile-time, which is funny.


This just means that it is computed by the compiler. For example...



There is no "hello", " ", or "world" strings created by the generated code. The generated code creates the "hello world" string directly -- because the result is computed at compile time. It is as if the code was ...



Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String literals