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):)

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

Well first you need to try and show us what you did. Then somebody will try to assist you.

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:)

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.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.