Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Why won't this compile?

 
Ranch Hand
Posts: 574
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is part of a larger program, but cutting everything after this yields the same error.
 
Sheriff
Posts: 67636
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you could share the error with us?

Edit: OK, now I see it. It'd be best not to hide parts of the post in the code comments. Cut and paste the error message exactly as the compiler displays it.

The syntax of that line is clearly wrong -- what exactly is it you are trying to do? Declare an inner class? Or define a method/constructor? The statement (incorrectly) has elements of both.
 
Greenhorn
Posts: 29
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First you need to remove the keyword class from the constructor in line 15 and second classname and constructor name must be the same.
 
Jim Venolia
Ranch Hand
Posts: 574
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahh. I'd removed class, and changed the name, but hadn't done both at the same time. Thanks.

It's an example off the googles on how to serialize an array of objects. Closest to my needs I can find.
 
Marshal
Posts: 75642
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please give us the link where you found that code. I suspect you have not copied it correctly.
 
Jim Venolia
Ranch Hand
Posts: 574
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would but I can't find it. I wanted to ask the author why it wouldn't compile, instead of asking here.
 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You didn't google it using serial number

http://www.byteslounge.com/tutorials/java-serializable-example
 
Jim Venolia
Ranch Hand
Posts: 574
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LOL. Never thought of it. I did google other strings in the source.

Hrmmm, that is not exactly the source I had pasted into my editor. Unfortunately I no longer have that original source either, I modified it to look more like what I need.

Serialization is kicking my gas pressure relief valve. I suspect I'm in Java 101 trying to figure out a Java 403 topic

Heh. I just realized that by looking for 1 more field in my parser then the results of my program can act as the save file. The whole point is to take reports from disparate sources and times and combine the info into 1 big array, which I then print out. I keep track of the source and date of the last time I saw each resource, this is the extra field I need to parse.

Dang, hours trying to serialize my data, 10 minutes to dump it and get my load/save working.
 
money grubbing section goes here:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic