-2

I need to name an Object: Dave's Account

I'm trying to do this using the following code:

Account Dave's Account = new Account;

but it's not working, I need the single quotation to be part of the name, is this possible?

Ziad
  • 103
  • 2

1 Answers1

0

That's the name of a variable, not the name of an object. Objects don't have a name.

And no, you may not have quotes, nor spaces, in a variable name. See http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8

An identifier is an unlimited-length sequence of Java letters and Java digits, the first of which must be a Java letter.

Identifier:
    IdentifierChars but not a Keyword or BooleanLiteral or NullLiteral

IdentifierChars:
    JavaLetter
    IdentifierChars JavaLetterOrDigit

JavaLetter:
    any Unicode character that is a Java letter (see below)

JavaLetterOrDigit:
    any Unicode character that is a Java letter-or-digit (see below)
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255