Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #11826

Re: Escape character for single quotes. Is it really required in String?

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Escape character for single quotes. Is it really required in String?
Date Tue, 7 Feb 2012 11:11:10 -0800 (PST)
Organization http://groups.google.com
Lines 30
Message-ID <5188996.160.1328641870734.JavaMail.geo-discussion-forums@pbctz9> (permalink)
References <93e3af31-e4d8-43df-9c03-9645b6885d1e@l16g2000vbl.googlegroups.com>
Reply-To comp.lang.java.programmer@googlegroups.com
NNTP-Posting-Host 173.164.137.214
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1328642776 14817 127.0.0.1 (7 Feb 2012 19:26:16 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Tue, 7 Feb 2012 19:26:16 +0000 (UTC)
In-Reply-To <93e3af31-e4d8-43df-9c03-9645b6885d1e@l16g2000vbl.googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=173.164.137.214; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11826

Show key headers only | View raw


On Tuesday, February 7, 2012 3:14:32 AM UTC-8, Mausam wrote:
> http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101089

That's the wrong document! Why are you citing ancient information? Get current.
http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html

> defines escape character for single character as well.
> 
> But single quote works fine in String without any escape character.
> 
> public class Class1 {
> 
>     private static String str = "I have a single quote. That's it";
>     private static String str1 = "I have a single quote. That\'s it";
>     public static void main(String[] args) {
>         System.out.println(str);
>         System.out.println(str1);
>     }
> }
> 
> How the two string is different?

Why do you claim that they're different?

> And when should I use escape character for single quote?

When you need to in order to make the expression mean what you intend.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Escape character for single quotes. Is it really required in String? Mausam <mausamhere@gmail.com> - 2012-02-07 03:14 -0800
  Re: Escape character for single quotes. Is it really required in String? Mausam <mausamhere@gmail.com> - 2012-02-07 03:18 -0800
  Re: Escape character for single quotes. Is it really required in String? Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-02-07 05:30 -0600
    Re: Escape character for single quotes. Is it really required in String? Mausam <mausamhere@gmail.com> - 2012-02-07 04:29 -0800
      Re: Escape character for single quotes. Is it really required in String? Knute Johnson <nospam@knutejohnson.com> - 2012-02-07 10:28 -0800
  Re: Escape character for single quotes. Is it really required in String? Lew <lewbloch@gmail.com> - 2012-02-07 11:11 -0800

csiph-web