File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes literal string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "literal string" Watch "literal string" New topic

literal string

WhyNot Ask

Joined: Apr 21, 2003
Posts: 2
i'm trying to change a string to literal, here is what i have for my code now:
current rule:
bind ?paramValue1 = new String ("12 months")
bind ?paramValue1 = (?paramValue1 + "12 months")
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

WhyNot Ask:
Howdy and Welcome to the JavaRanch! We hope you’ll enjoy visiting the site on a regular basis. However, your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!
[ April 21, 2003: Message edited by: Jamie Robertson ]
Greg Charles

Joined: Oct 01, 2001
Posts: 2968

Is there a question in there? It looks like you are defining a syntax, and maybe writing a parser for it. Even if I've guessed that much correctly, I'm still not sure what your question is.
WhyNot Ask

Joined: Apr 21, 2003
Posts: 2
just wanted to know if the change will make it a literal value vs a string - i hope this answers your question - i'm a newbie!
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Originally posted by WhyNot Ask:
a literal value vs a string

hmmmm . . . they are not opposing things.
Strings can be literals if they are specified at compile time. Being a literal is just an efficiency that the JVM uses.
String x = "12 months";
In this case x is a variable that references a String that is a literal. Since it can be resolved at compile time it is a literal.
final String x = "12 months";
Now we have made variable a constant, always referencing the same String literal.
String x = new String(args[0]);
In this case the value of the String can not be resolved at compile time.
[ April 22, 2003: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
You might try reading
3.10.5 String Literals from the Java Language Specification.
I agree. Here's the link:
subject: literal string
jQuery in Action, 3rd edition