• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

illegal start of an expression

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting a gigantic pile of errors that clearly arent correct, which tells me a lot of this can be fixed with just one or two changes.


BenHultinProg4.java:22: illegal start of type
for (i = 1; i < 13; i++) {
^
BenHultinProg4.java:22: <identifier> expected
for (i = 1; i < 13; i++) {
^
BenHultinProg4.java:22: ';' expected
for (i = 1; i < 13; i++) {
^
BenHultinProg4.java:24: <identifier> expected
saver1.getBalance()
^
BenHultinProg4.java:24: ';' expected
saver1.getBalance()
^
BenHultinProg4.java:27: <identifier> expected
saver2.getBalance()
^
BenHultinProg4.java:27: ';' expected
saver2.getBalance()
^
BenHultinProg4.java:30: <identifier> expected
System.out.printf(DATA_FMT_STR, 0, saver1.getACCOUNT_NUMBER(), saver1.ba
lance,
^
BenHultinProg4.java:30: <identifier> expected
System.out.printf(DATA_FMT_STR, 0, saver1.getACCOUNT_NUMBER(), saver1.ba
lance,
^
BenHultinProg4.java:30: illegal start of type
System.out.printf(DATA_FMT_STR, 0, saver1.getACCOUNT_NUMBER(), saver1.ba
lance,
^
BenHultinProg4.java:30: <identifier> expected
System.out.printf(DATA_FMT_STR, 0, saver1.getACCOUNT_NUMBER(), saver1.ba
lance,
^
BenHultinProg4.java:30: ';' expected
System.out.printf(DATA_FMT_STR, 0, saver1.getACCOUNT_NUMBER(), saver1.ba
lance,
^
BenHultinProg4.java:30: illegal start of type
System.out.printf(DATA_FMT_STR, 0, saver1.getACCOUNT_NUMBER(), saver1.ba
lance,
^
BenHultinProg4.java:30: ';' expected
System.out.printf(DATA_FMT_STR, 0, saver1.getACCOUNT_NUMBER(), saver1.ba
lance,
^
BenHultinProg4.java:30: <identifier> expected
System.out.printf(DATA_FMT_STR, 0, saver1.getACCOUNT_NUMBER(), saver1.ba
lance,

^
BenHultinProg4.java:31: ';' expected
saver2.getACCOUNT_NUMBER(), save
r2.balance);
^
BenHultinProg4.java:31: invalid method declaration; return type required
saver2.getACCOUNT_NUMBER(), save
r2.balance);
^
BenHultinProg4.java:31: ';' expected
saver2.getACCOUNT_NUMBER(), save
r2.balance);
^
BenHultinProg4.java:44: class, interface, or enum expected
}
^
49 errors






Here is my driver file:




here is my driven class:




I appreciate any help in the matter
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main problem with your class BenHultinProg4 is that you are putting all kinds of statements directly in the class declaration. That doesn't work. You need to create methods, and put those statements inside methods. You can't, for example, call System.out.printf(...) at class level. You can only do that inside a method.
 
Marshal
Posts: 22457
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or a method or (static) initializer block. But no, not directly in the class.
 
Marshal
Posts: 74054
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And don't write more than about 5 lines of code before you try compiling it. That many errors suggests you are trying to write dozens of lines, and will get all confused by the many errors.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic