CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012
    Posts
    17

    Question Printing literal quotes with strings and variables

    Hi I'm trying to find out how to display my variable with quotes around it.
    I've tried all types of things and get get it to work. with back slashes and such.


    caseNum is my variable that I want quotes around.

    I've tried these and none of them worked
    System.out.println("Case"+" "+ caseNum);
    System.out.println("Case"+" "+ "\"caseNum\"");

    What am I doing wrong?

  2. #2
    Join Date
    Feb 2012
    Posts
    17

    Re: Printing literal quotes with strings and variables

    System.out.println("Case"+" "+ ""+ caseNum+""); this didnt work either

  3. #3
    Join Date
    Nov 2006
    Location
    Barcelona - Catalonia
    Posts
    364

    Re: Printing literal quotes with strings and variables

    Code:
    System.out.println("Case \"" + caseNum + "\"");
    Regards,

    Albert.
    Please, correct me. I'm just learning.... and sorry for my english :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured