help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abuyetemam
    New Member
    • Mar 2008
    • 2

    help

    [CODE=java]
    public class test{
    public static void main()
    {
    a1(new int[]{1, 2, 3, 4});
    }

    static int a1(int[] a)
    {
    int max1 = -1;
    int max2 = -1;

    for (int i=0; i<a.length; i++)
    {
    if (a[i] > max1)
    {
    max2 = max1;
    max1 = a[i];
    }
    else if (a[i] != max1 && a[i] > max2)
    max2 = a[i];
    }

    return max2;
    }
    }// end of class test
    [/CODE]
    please help me what is wrong with this code, my compiler generates error in the third line that as '( 'and ')'are expected , thank you all !!
    Last edited by r035198x; Mar 28 '08, 09:54 AM. Reason: added code tags, please don't forget them next time
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    1.) Please use code tags everytime when posting code
    2.) Is that all the code you typed into the compiler? Where the class declaration?

    Edit:
    3.) Use appropriate titles for your threads as explained in the posting guidelines.

    Comment

    • pralu
      New Member
      • Mar 2008
      • 34

      #3
      Code:
      a1(new int[]{1, 2, 3, 4});
      can anyone plz explain me what actually happening here

      Comment

      • pralu
        New Member
        • Mar 2008
        • 34

        #4
        Originally posted by r035198x
        1.) Please use code tags everytime when posting code
        2.) Is that all the code you typed into the compiler? Where the class declaration?

        Edit:
        3.) Use appropriate titles for your threads as explained in the posting guidelines.

        hai jos... its ok... right .....every one at some stage does sum mistake dat doesnt mean u will horn them.... its ok chilll

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by pralu
          hai jos... its ok... right .....every one at some stage does sum mistake dat doesnt mean u will horn them.... its ok chilll
          This is utterly confusing: you're quoting r035198x and you're talking to me. Read
          my latest reply in your other thread: don't post spoon feeding code, don't just
          supply answers without an explanation and don't keep on opening new threads
          for one single problem. I warned you a couple of times and I don't want to keep
          doing that.

          kind regards,

          Jos (mod)

          Comment

          • radhikams
            New Member
            • Jan 2008
            • 49

            #6
            Originally posted by pralu
            Code:
            a1(new int[]{1, 2, 3, 4});
            can anyone plz explain me what actually happening here
            As per my knowledge This is actually goes in following steps
            Code:
             int[] a;
               a=new int[]{1,2,3,4};
               a1(a) ;

            a1(new int[]{1, 2, 3, 4}); is the combination of above steps.

            Thanks

            Comment

            Working...