?
Solved

Newbie help

Posted on 2005-04-20
8
Medium Priority
?
205 Views
Last Modified: 2010-03-31
Hi,
I am just starting out on java

can u tell me what am doing wrong here

class Myclass
{
      public static void main(String[] args)
      {
            //System.out.println("Hello World!");
            printLargestAndSmallest(1,2,3,4,5);
      }
            static void printLargestAndSmallest( int[] n){
                  int max = n[0];
                  int min = n[0];
                  for(int i =1; i <n.length; i++)
                  {
                        if(max <n[i]){
                              max = n[i];
                        }
                              if(min > n[i])
                        {
                                    min = n[i];
                        }
                  }
                  System.out.println("Maximum:" + max);
                  System.out.println("Minimum:" +min);
            }
}
0
Comment
Question by:archrajan
  • 4
  • 2
  • 2
8 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 13823814
>>printLargestAndSmallest(1,2,3,4,5);

should be

printLargestAndSmallest(new int[] {1,2,3,4,5 });
0
 
LVL 8

Expert Comment

by:koppcha
ID: 13823831
>printLargestAndSmallest(1,2,3,4,5);
   You are passing seperate arguments
0
 
LVL 25

Author Comment

by:archrajan
ID: 13823842
Gotcha! Thanks a ton!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 13823847
           int max = Integer.MIN_VALUE;
            int min = Integer.MAX_VALUE;
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13823856
(As you need to begin with an appropriate initialization)
0
 
LVL 8

Expert Comment

by:koppcha
ID: 13823857
Glad to see you agian archana
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13823862
:-)
0
 
LVL 25

Author Comment

by:archrajan
ID: 13823868
Yeah, will see me again a lot in java as a questioner ;)
thanks...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question