• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why won't this compile?  RSS feed

 
Ranch Hand
Posts: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is part of a larger program, but cutting everything after this yields the same error.
 
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • 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: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • 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: 56610
172
  • Mark post as helpful
  • send pies
  • 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: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • 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: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • 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: 312
2
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!