GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Syntax Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Syntax Error" Watch "Syntax Error" New topic
Author

Syntax Error

Ron Buzan
Greenhorn

Joined: Sep 07, 2012
Posts: 2

I hate to be the noob. I thought I had worked the kinks out of this code, but the last remaining error is right at Line 1 with: "Syntax error on token(s), misplaced constructor(s)." I can attach the account class if needed.

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30586
    
154

Ron Buzan wrote: I can attach the account class if needed.

Please do. I think the error is in there.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ron Buzan
Greenhorn

Joined: Sep 07, 2012
Posts: 2

That's what I was afraid of. Note - there are one or two elements in here I haven't tied in yet (DecimalFormat..), they're just hanging out til I get the thing to compile.

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

This code is not in a single file, is it ?


[My Blog]
All roads lead to JavaRanch
Niranjan Aithal
Greenhorn

Joined: Mar 17, 2012
Posts: 6
Check your java version. There is nothing wrong with the code you have pasted. Autoboxing feature offered from Tiger (1.5) release of Java SDK.
try this :
Account account = new Account(1122, 20000d);

As Christophe pointed, if this is a single file put the import statement at the beginning :
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Niranjan, this has nothing to do with Java5 autoboxing feature. An int is casted into a double in previous versions too.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39076
    
  23
Why are you using DecimalFormat rather than the % tags?
Niranjan Aithal
Greenhorn

Joined: Mar 17, 2012
Posts: 6
Christophe Verré wrote:Niranjan, this has nothing to do with Java5 autoboxing feature. An int is casted into a double in previous versions too.

Thanks Christophe.
 
GeeCON Prague 2014
 
subject: Syntax Error