This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Array Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array Method" Watch "Array Method" New topic
Author

Array Method

Amy Lee
Greenhorn

Joined: Nov 02, 2004
Posts: 25
I'm writing a method that takes a single parameter which is an array of ints and returns the number of elements in that array that are greater than the first element. My code is as follows:



When I enter into the method call new int[] {1,2,3}, it returns 2 which is correct. But when I enter in the method call new int[] {2,1,3}, it again returns 2 when it was expected to return 1. I can't figure out why it's doing this.

Thanks.
Karthikeyan Rajendraprasad
Ranch Hand

Joined: Apr 16, 2003
Posts: 70
there is a semi-colon at the end of if statement remove it and it will work fine



Karthikeyan<br />SCJP 1.4, SCWCD.
Amy Lee
Greenhorn

Joined: Nov 02, 2004
Posts: 25
Wow, I didn't even notice that...must have typed that by accident. Thanks!

Amy
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Array Method
 
It's not a secret anymore!