Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Given a vague question, I have to guess a lot, but perhaps it's something like this you're looking for:</p> <pre><code>import java.util.*; public class Test { static Map&lt;Integer, Integer&gt; groups = new HashMap&lt;Integer, Integer&gt;(); public static void main(String... args) { groups.put(1, 2); groups.put(2, 3); groups.put(2, 4); groups.put(4, 5); System.out.println(searchFor(1, 5)); } private static String searchFor(int from, int target) { // Target found? if (from == target) return "" + target; // Dead end? if (!groups.containsKey(from)) return null; // Recurse and try to find it from here. String path = searchFor(groups.get(from), target); return path == null ? null : from + " -&gt; " + path; } } </code></pre> <p><strong>Output:</strong> 1 -> 2 -> 4 -> 5</p> <hr> <p>Or something like this:</p> <pre><code> static Map&lt;Integer, Group&gt; groups = new HashMap&lt;Integer, Group&gt;(); public static void main(String... args) { groups.put(0, new Group(1, "hello")); // (0: -) -&gt; (1: "hello") groups.put(2, new Group(9, "!")); // (2: "world") -&gt; (9, "!") groups.put(3, new Group(5, "bye")); // (3: -) -&gt; (5, "bye") groups.put(1, new Group(2, "world")); // (1: "hello") -&gt; (2: "world") System.out.println(traverse(0)); } private static String traverse(int from) { if (!groups.containsKey(from)) return ""; String path = traverse(groups.get(from).idGroupe); return path == null ? null : groups.get(from).word + " " + path; } } </code></pre> <p>Which prints:</p> <pre><code>hello world ! </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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