Note that there are some explanatory texts on larger screens.

plurals
  1. POadding value on treeset
    text
    copied!<p>ı read text. my text is like that</p> <pre><code>AYSE;SERDAR-9.8;EMRE-5.2;AYTAC-3.3 FATMA;OYTUN-8.8;ORKUN-7.5;ONUR-5.4;UMUT-4.4;BERK-3.3;CAN-3.2 DERYA;VELI-7.7;ALI-6.5;SUAT-6.0;YAVUZ-5.0;OYTUN-4.2;ORKUN-3.1 DILARA;DOGUS-8.8;VELI-7.4;ALI-6.5;SUAT-5.5;YAVUZ-3.1 BEGUM;SUAT-6.6;YAVUZ-5.1;OYTUN-4.3;ORKUN-4.0 BERIL;CANER-8.7;DOGUS-7.5;VELI-6.2;ALI-6.1;SUAT-5.8;YAVUZ-4.8;OYTUN-4.0 FUNDA;ORKUN-9.7;ONUR-8.3;UMUT-7.2;BERK-6.5;CAN-5.5 ISIL;AYTAC-8.3;CANER-7.4;DOGUS-6.5;VELI-5.5;ALI-5.4;SUAT-4.4;YAVUZ-4.0;OYTUN-3.9;ORKUN-3.5;ONUR-3.4;UMUT-3.2;BERK-3.1;CAN-3.0 ELIF;EMRE-7.4;AYTAC-6.1 </code></pre> <p>ı cant add "u.eleman" and "u.uyum" values to "treeset tSU". it gives memory address when ı do syso ı cant see them in the tSU TREESET. I want to add all of them to treeset. How can ı do that.. please help</p> <pre><code>import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.HashSet; import java.util.TreeSet; public class Rapor { static class Uyum implements Comparable&lt;Uyum&gt; { String eleman; Double uyum; public int compareTo(Uyum u) { if (uyum &lt; u.uyum) return -1; if (uyum &gt; u.uyum) return 1; return 0; } } public static void main(String[] args) { FileInputStream fIS; try { fIS = new FileInputStream("C:\\deneme\\rapor.txt"); Reader r; r = new InputStreamReader(fIS, "UTF-8"); BufferedReader bR = new BufferedReader(r); String satır; String[] point, p2; while ((satır = bR.readLine()) != null) { point = satır.split(";"); String kelime = point[0]; HashMap&lt;String, TreeSet&lt;Uyum&gt;&gt; uyumlar = new HashMap&lt;String, TreeSet&lt;Uyum&gt;&gt;(); TreeSet&lt;Uyum&gt; tSU = new TreeSet&lt;Uyum&gt;() ; Uyum u ; for (int i = 1; i &lt; point.length; i++) { p2=point[i].split("\\-"); u = new Uyum(); u.eleman = p2[0];//EMRE,AYTAC,.. u.uyum = Double.parseDouble(p2 [1]);//7.8,9.5 tSU.add(u); } uyumlar.put(kelime, tSU); System.out.println(uyumlar); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }// main end }// class end </code></pre>
 

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