hi, i have a problem comparing values in an array and how to display them

sample:

int[] d = new int[c];
     
for(i=0,j=1;i<d.length;i++,j++){
       
        d[i]=Integer.parseInt(JOptionPane.showInputDialog("Enter value : "+j));

        }

i don't know how to start comparing values of each index's in the array..can someone help me? thanks BTW(new to this forum):)

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

I can give quick solution, but that will not help you in your learning process.

Instead you gone tell me what such process have to in order to compare two arrays. Just plane words no need for code yet

sorry for the late reply(I was busy)...anyhow i want to compare values of a single array. Compare the first input value at index 0..my instructor told me i could use if-statements but i don't now what to compare and how to print those values...thanks:D

So far this is what i have and it does not work.

for(i=1;i<d.length;i++){
        if(d[0]>d[i])
           right+=d[i];
           
        }
        System.out.println("left tree:"+right);


        for(i=1;i<d.length;i++){
       if(d[0]<d[i])
           left=d[1];
      
        }
        System.out.println("right tree:"+left);

BTW sorry for the code iam still trying to learn how to post codes:)

Edited 5 Years Ago by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

Sorry to say, but that code is wrong.
Lets start with explanation of what your application is supposed to do.
(waiting for user input, input stored in array, etc.)

This article has been dead for over six months. Start a new discussion instead.