i am complete beginner, i use eclipse.
i need to create an array with attributes name, gender, phone, age.
and then sort acording to age in ascending order.
i created like this,
This code sorts the age attribute alone and when printing ouput it swaps one person's age to other person, how to make it correctpublic class Array{ private String[] name={"ram", "katy", "priti", "john"}; private String[] gender={"male","female","female","male"}; private int[] phone={989898089,89898989,8982989089,898908989}; private int[] age={45,24,30,28}; public void printarray(){ for(int i=0;i<=4;i++) System.out.printf("%s %s %d %d \n",name[i],gender[i],phone[i],age[i]); // sorting for(int i=0; i<4;++i) { for(int j=i+1; j<5; ++j) { if(age[i]>age[j]) { int a = age[i]; age[i] = age[j]; age[j] = a; } } } for (int i = 0; i < 5; ++i){ System.out.printf("%s %s %s %d \n",name[i],gender[i],mail[i],marks[i]); } } }