Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Welcome to SO.</p> <p>First of all, there are Java conventions to name the variables. Have a look at the <a href="http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html" rel="nofollow noreferrer"> Naming conventions</a></p> <p>Secondly, Java is an Object Oriented Language, so you have to change your mind a little bit about how you approach problems.</p> <p>In this particular case, you want all the data scattered among 3 arrays to be together. Well, create a class for it.</p> <pre><code>public class Data implements Comparable{ private String title; private String desc; private int num; public Data(String title, String desc, int num){ //set the private fields here } //You may want to write some setters and getters here for individual fields. public int compareTo(Object o){ //here you compare an item with other item. Remember to cast the object o to Data. // Read http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Comparable.html to know what to return } } </code></pre> <p>And then in your main class:</p> <pre><code>int item = 0; do { Data group = new Data(arr_title.get(item),arr_desc.get(item),arr_num.get(item); groupData.add(group); item++; } while (item &lt; arr_num.size()); Collections.sort(groupData); </code></pre> <p>Last but not least, there are better ways to iterate through a set in Java. Read about <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Iterator.html" rel="nofollow noreferrer">Iterators</a>. It's a much secure and cleaner way to go through an array or a set.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload