• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble with an assignment  RSS feed

 
Kyle Lykens
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I'm very new to Java, but I need to learn because I'm an IT major 10 weeks into a programming course. We have an assignment related to arrays, and searching for information in arrays. I emailed my professor asking about an error, and he sent me back a code to use in the program, but that is returning errors. I have a feeling it's due to the fact that I just got a new computer, and the filepaths and whatnot. This is what I have for code:


And I get the following errors:

5 errors found:
File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 15]
Error: missing method body, or declare abstract
File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 17]
Error: cannot find symbol
symbol: variable fullName
location: class Assignment8
File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 18]
Error: cannot find symbol
symbol: variable fullName
location: class Assignment8
File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 20]
Error: cannot find symbol
symbol: variable indexList
location: class Assignment8
File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 26]
Error: incompatible types
required: java.lang.Integer
found: java.lang.Object

As far as I can tell, the variables all look declared, so I don't know the problem. I need to figure it out before I add on two more methods and arrays for salary and zip code. If you could offer an explanation along with the correction(s) that need to be made, it would be greatly appreciated.

Thanks!
 
Kyle Lykens
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I edited it with the proper code. Thanks for bringing that to my attention!

Edit: We also never learned about indentation in class, so I'm not sure what you mean. Do you have a link for that, too?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle Lykens wrote:


File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 15]
Error: missing method body, or declare abstract

As far as I can tell, the variables all look declared, so I don't know the problem. I need to figure it out before I add on two more methods and arrays for salary and zip code. If you could offer an explanation along with the correction(s) that need to be made, it would be greatly appreciated.
Edit: I added arrows to the error lines to make it easier to read.


Hint: Java syntax is very specific. You can't just have extra semi-colons in certain locations.

 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle Lykens wrote:I edited it with the proper code. Thanks for bringing that to my attention!


Do you really don't use indentation at all?

Henry
 
Kyle Lykens
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! Although, taking out that semicolan got rid of the first four errors, but left the fifth one:

File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 26]
Error: incompatible types
required: java.lang.Integer
found: java.lang.Object

Does this have to do with an import that I didn't use?

Also, henry, no, we never learned about indentation. If anyone has a link so I can check it out, I'd love to see it.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indentation is simply moving blocks of code over a bit, to help identify where various parts start and stop.

GENERALLY, each time you have an open curly bracket, you start indenting the next lines of code some fixed amount. They are cumulative. Each time you hit a closing brace, the next lines are un=indented. Your code should look SORT OF like this:


The other important thing is to be consistant with your braces. Sometimes, you have them on lines by themselves, and sometimes you have them on the end of a line. Both are allowed by java, but it is VASTLY preferred for you to always do it the same way withing a single file.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle Lykens wrote:
Also, henry, no, we never learned about indentation. If anyone has a link so I can check it out, I'd love to see it.



Indentation is just formatting. It is used to make code more readable. For example, which is more readable?





Henry
 
Kyle Lykens
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, yes. Indentation does make it much more readable, and seems fairly simple. Thank you both!

Edit: Also, this warning message appears alongside the error:

*** Error ***
-------------
File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 30]
Error: incompatible types
required: java.lang.Integer
found: java.lang.Object
-------------
** Warning **
-------------
File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 23]
Warning: unchecked call to add(E) as a member of the raw type java.util.ArrayList
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle Lykens wrote:
File: C:\Users\Kyle\Summer 13\CISS 110\Assignment8.java [line: 30]
Error: incompatible types
required: java.lang.Integer
found: java.lang.Object



Line 30 of Assignment8.java, you are calling / using something that requires an Integer -- and you are not providing one.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!