• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sequential Search of Arrays - Compile Error  RSS feed

 
Rachel Green
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a hard time getting my sequentialSearch method to work. I wrote the first code, and now want to use the same searching method in the second code. I can't figure out how to edit the header to apply to the new code.

First code where sequentialSearch is working:

Second code, where sequentialSearch is causing compiler errors:

 
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
Rachel Green wrote:
Second code, where sequentialSearch is causing compiler errors:


Generally, with compiler errors, it is a good idea to post the error messages from the compiler. Also, how you are running the compiler too.

Henry
 
Rachel Green
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the error when I compile:
 
Rachel Green
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the full error message:
 
Junilu Lacar
Sheriff
Posts: 11477
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your ints variable is an array of primitive integer values. You can use an array of Integer instead, which is a wrapper class for the primitive int integer type.  You'd get the same kind of error if you had used double[] instead of Double[] for your numbers variable.
 
Rachel Green
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's it! Thank you SO much. I actually didn't know there was a difference, now I know what I need to talk to my professor about. This has been so helpful in guiding me in the right direction. Thanks again.
 
Junilu Lacar
Sheriff
Posts: 11477
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is where knowing standard Java naming conventions can help programmers understand what's going on.

In Java, reference type names (classes, interfaces, enums) are capitalized by convention. So, it's easy to differentiate the wrapper class Integer from its corresponding primitive type  int, for example. Primitive types have names that are in lowercase so you have double, float, byte, char, short, int, long, and boolean. The corresponding wrapper classes follow Java naming conventions and are capitalized: Double, Float, Byte, Character, Short, Integer, Long, and Boolean.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!