• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

literal string

 
WhyNot Ask
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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")
proposed:
bind ?paramValue1 = (?paramValue1 + "12 months")
thanks,
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
Jamie
[ April 21, 2003: Message edited by: Jamie Robertson ]
 
Greg Charles
Sheriff
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might try reading
3.10.5 String Literals from the Java Language Specification.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic