java - sorting on ArrayList but ArrayList have same value -


my text is

---- sınİsıru, sınİuzo puanları azalan : ------ {deneme deneme deneme}{anya}{ltd. Ştİ.}{1.75}{1.25}{14.00}{10.00}{1.75}{1.2}{false} ------ {deneme deneme deneme }{dzlİ}{ Ştİ.}{1.43}{1.14}{11.43}{9.14}{1.43}{0.57}{false} ------ {deneme deneme deneme }{meİn}{ Ştİ.}{1.29}{1.10}{10.29}{8.76}{1.29}{0.55}{false} ------ {deneme deneme deneme }{hay}{ Ştİ.}{1.29}{1.10}{10.29}{8.76}{1.29}{0.55}{false} ------ {deneme deneme deneme }{ahan}{ Ştİ.}{1.29}{1.10}{10.29}{8.76}{1.29}{0.55}{false} ------ {deneme deneme deneme }{msa}{ Ştİ.}{1.29}{1.10}{10.29}{8.76}{1.29}{0.55}{false} ------ {deneme deneme deneme }{Ş}{ Ştİ.}{1.29}{1.10}{10.29}{8.76}{1.29}{0.55}{false} ------ {deneme deneme deneme }{ko}{. Ştİ.}{1.25}{1.08}{10.00}{8.67}{1.25}{0.54}{false} 

kolon1:1.75,1.43,1.29...

kolon2:1.25,1.14,1.10..

then ı sorted them smallest bigger.

there replaced number ı dont want replaced number. exemaple if contain text contain 3,3,3,3,3,2,2,2,2,1,1,1,1,1,1

ı want 1 2 3

 public class pointstatue {       private static list<double> col1 = new arraylist<double>();      private static list<double> col2 = new arraylist<double>();     private static list<double> col3 = new arraylist<double>();     private static  list<double> col4 = new arraylist<double>();     private static list<double> col5 = new arraylist<double>();     private static list<double> col6 = new arraylist<double>();     private static list<double> list=new arraylist<double>();       private static list<double> numbers = new arraylist<double>();      public static void main(string[] args) throws ioexception {          arraylist<string> puan;         puan = okudiziyekoy("c:\\deneme\\hw.txt");         system.out.format("%d kayıt okundu.%n", puan.size());          (int j = 0; j < puan.size(); j++) {              string point = puan.get(j);              string[] edit = point.split("[\\{\\}\\)]");              (string s : edit) {                  string = s.replaceall("[\\}\\-\\>\\>\\]\\[\\#\\*\\{]+", "");                 string b = a.replaceall("[\\.]+", ",");                 scanner scanner = new scanner(b);                  while (scanner.hasnext()) {                      if (scanner.hasnextdouble()) {                         double doublevalue = scanner.nextdouble();                           numbers.add(doublevalue);                         // system.out.println(arrays.deeptostring(numbers.toarray()));                      }// if scan end                      else {                          //if string comes value here                         string stringvalue = scanner.next();                      }// if scan end                  }// while end              }// string s          }// j end           int col=1;          for(int i=0;i<numbers.size();i++)         {              double rowvalue = numbers.get(i);              switch(col)             {             case 1:                 col1.add(rowvalue);                 collections.sort(col1);                 col++;                 break;             case 2:                 col2.add(rowvalue);                 collections.sort(col2);                 col++;                 break;             case 3:                 col3.add(rowvalue);                 collections.sort(col3);                 col++;                 break;             case 4:                 col4.add(rowvalue);                 collections.sort(col4);                 col++;                 break;             case 5:                 col5.add(rowvalue);                 collections.sort(col5);                 col++;                 break;             case 6:                 col6.add(rowvalue);                 collections.sort(col6);                 col = 1;                 break;              }//switch end          }//for end           system.out.println("kolon1"+col1);         system.out.println("kolon2"+col2);         system.out.println("kolon3"+col3);         system.out.println("kolon4"+col4);         system.out.println("kolon5"+col5);         system.out.println("kolon6"+col6);      }// main end      private static arraylist<string> okudiziyekoy(string dosyaadı) {          arraylist<string> dizi = new arraylist<string>();         try {             fileinputstream fis;             fis = new fileinputstream(dosyaadı);             reader r = new inputstreamreader(fis, "iso-8859-9");             bufferedreader br = new bufferedreader(r);             string satır;              while ((satır = br.readline()) != null) {                 dizi.add(satır);              }         } catch (filenotfoundexception e) {             e.printstacktrace();         } catch (unsupportedencodingexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         }         return dizi;     }// okudiziyekoyend  }// class end 

try this, finds duplicate values in rows, , each row too, works me :)

/* import java.util.arraylist; import java.util.collections; import java.util.list; public class dupremove { public static void main(string...arg){    double val[]={1,4.3,5,2,4,4,4,6.5,2,2,2,2,2,3.5,3.7,4,7,8,9};   for(int i=0;i<val.length;i++){     add(val[i]);   }   collections.sort(list);   system.out.println(list);  } static list<double> list=new arraylist<>(); public static void add(double d){   if(!list.contains(d)){list.add(d);} } } */  import java.io.bufferedreader; import java.io.file; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.ioexception; import java.io.inputstreamreader; import java.util.*; public class pointstatue { /*private static list<double> col1 = new arraylist<double>();  private static list<double> col2 = new arraylist<double>(); private static list<double> col3 = new arraylist<double>(); private static list<double> col4 = new arraylist<double>(); private static list<double> col5 = new arraylist<double>(); private static list<double> col6 = new arraylist<double>(); private static list<double> col7 = new arraylist<double>(); private static list<double> col8 = new arraylist<double>();*/ //private static list<double> list=new arraylist<double>(); private static arraylist<list<double>> rows=new arraylist<list<double>>();  private static list<double> numbers = new arraylist<double>(); private static void okudiziyekoy(string path,arraylist<string> arr) throws exception{   bufferedreader br=new bufferedreader(new inputstreamreader(new fileinputstream(path)));   //skip first line   br.readline();   string g;   while((g=br.readline())!=null){     arr.add(g);   } } public static void main(string[] args) throws exception {     arraylist<string> puan = new arraylist<string>();     okudiziyekoy("c:/deneme/hw.txt", puan);     //   puan = okudiziyekoy("c:\\deneme\\hw.txt");     system.out.format("%d kayıt okundu.%n", puan.size());     double doublevalue;      (int j = 0; j < puan.size(); j++) {       list<double> listtoadd=new arraylist<double>();         rows.add(j, listtoadd);         string point = puan.get(j);         //split data(line) }{         string[] edit = point.split("[}][{]");         for(int l=3;l<edit.length-1;l++){           //parsing string double           doublevalue=double.parsedouble(edit[l]);           //check if double value not exist add list           if(!numbers.contains(doublevalue)){           numbers.add(doublevalue);           }           if(!listtoadd.contains(doublevalue)){             listtoadd.add(doublevalue);           }         }        /* (string s : edit) {              string = s.replaceall("[\\}\\-\\>\\>\\]\\[\\#\\*\\{]+", "");             string b = a.replaceall("[\\.]+", ",");             scanner scanner = new scanner(b);              while (scanner.hasnext()) {                  if (scanner.hasnextdouble()) {                      doublevalue = scanner.nextdouble();                     if(!numbers.contains(doublevalue)){                     numbers.add(doublevalue);                     }                     // system.out.println(arrays.deeptostring(numbers.toarray()));                  }// if scan end                  else {                      //if string comes value here                     string stringvalue = scanner.next();                  }// if scan end              }// while end          }// string s      }// j end*/          }     collections.sort(numbers);     system.out.println("unique values(in rows): ");     for(double d :numbers){         system.out.print(d+" ");       }     system.out.println();     /*int col=1;     for(int i=0;i<numbers.size();i++)     {          double rowvalue = numbers.get(i);          switch(col)         {         case 1:             col1.add(rowvalue);              col++;             break;         case 2:             col2.add(rowvalue);              col++;             break;         case 3:             col3.add(rowvalue);              col++;             break;         case 4:             col4.add(rowvalue);              col++;             break;         case 5:             col5.add(rowvalue);              col++;             break;         case 6:             col6.add(rowvalue);              col = 1;             break;          }//switch end      }//for end*/    /* collections.sort(col1);     collections.sort(col2);     collections.sort(col3);     collections.sort(col4);     collections.sort(col5);     collections.sort(col6);*/     /*system.out.println("kolon1 "+col1);     system.out.println("kolon2 "+col2);     system.out.println("kolon3 "+col3);     system.out.println("kolon4 "+col4);     system.out.println("kolon5 "+col5);     system.out.println("kolon6 "+col6);*/     //sorting each row     for(int i=0;i<rows.size();i++){       collections.sort(rows.get(i));     }     //showing each row(array)     for(int i=0;i<rows.size();i++){       system.out.println("kolon"+i+": "+rows.get(i));     }  }// main end   } 

dup in columns:

/* import java.util.arraylist; import java.util.collections; import java.util.list; public class dupremove { public static void main(string...arg){    double val[]={1,4.3,5,2,4,4,4,6.5,2,2,2,2,2,3.5,3.7,4,7,8,9};   for(int i=0;i<val.length;i++){     add(val[i]);   }   collections.sort(list);   system.out.println(list);  } static list<double> list=new arraylist<>(); public static void add(double d){   if(!list.contains(d)){list.add(d);} } } */  import java.io.bufferedreader; import java.io.file; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.ioexception; import java.io.inputstreamreader; import java.util.*; public class pointstatue { /*private static list<double> col1 = new arraylist<double>();  private static list<double> col2 = new arraylist<double>(); private static list<double> col3 = new arraylist<double>(); private static list<double> col4 = new arraylist<double>(); private static list<double> col5 = new arraylist<double>(); private static list<double> col6 = new arraylist<double>(); private static list<double> col7 = new arraylist<double>(); private static list<double> col8 = new arraylist<double>();*/ //private static list<double> list=new arraylist<double>(); private static arraylist<list<double>> rows=new arraylist<list<double>>();  private static list<double> numbers = new arraylist<double>(); private static void okudiziyekoy(string path,arraylist<string> arr) throws exception{   bufferedreader br=new bufferedreader(new inputstreamreader(new fileinputstream(path)));   //skip first line   br.readline();   string g;   while((g=br.readline())!=null){     arr.add(g);   } } public static void main(string[] args) throws exception {     arraylist<string> puan = new arraylist<string>();     okudiziyekoy("c:/deneme/hw.txt", puan);     //   puan = okudiziyekoy("c:\\deneme\\hw.txt");     system.out.format("%d kayıt okundu.%n", puan.size());     double doublevalue;     (int j = 0; j < 6; j++) {       rows.add(new arraylist<double>());     }     (int j = 0; j < puan.size(); j++) {         string point = puan.get(j);         //split data(line) }{         string[] edit = point.split("[}][{]");         for(int l=3;l<edit.length-1;l++){           //parsing string double           doublevalue=double.parsedouble(edit[l]);           //check if double value not exist add list           if(!numbers.contains(doublevalue)){           numbers.add(doublevalue);           }           if(!rows.get(l-3).contains(doublevalue)){             rows.get(l-3).add(doublevalue);           }         }        /* (string s : edit) {              string = s.replaceall("[\\}\\-\\>\\>\\]\\[\\#\\*\\{]+", "");             string b = a.replaceall("[\\.]+", ",");             scanner scanner = new scanner(b);              while (scanner.hasnext()) {                  if (scanner.hasnextdouble()) {                      doublevalue = scanner.nextdouble();                     if(!numbers.contains(doublevalue)){                     numbers.add(doublevalue);                     }                     // system.out.println(arrays.deeptostring(numbers.toarray()));                  }// if scan end                  else {                      //if string comes value here                     string stringvalue = scanner.next();                  }// if scan end              }// while end          }// string s      }// j end*/          }     collections.sort(numbers);     system.out.println("unique values(in rows): ");     for(double d :numbers){         system.out.print(d+" ");       }     system.out.println();     /*int col=1;     for(int i=0;i<numbers.size();i++)     {          double rowvalue = numbers.get(i);          switch(col)         {         case 1:             col1.add(rowvalue);              col++;             break;         case 2:             col2.add(rowvalue);              col++;             break;         case 3:             col3.add(rowvalue);              col++;             break;         case 4:             col4.add(rowvalue);              col++;             break;         case 5:             col5.add(rowvalue);              col++;             break;         case 6:             col6.add(rowvalue);              col = 1;             break;          }//switch end      }//for end*/    /* collections.sort(col1);     collections.sort(col2);     collections.sort(col3);     collections.sort(col4);     collections.sort(col5);     collections.sort(col6);*/     /*system.out.println("kolon1 "+col1);     system.out.println("kolon2 "+col2);     system.out.println("kolon3 "+col3);     system.out.println("kolon4 "+col4);     system.out.println("kolon5 "+col5);     system.out.println("kolon6 "+col6);*/     //sorting each row     for(int i=0;i<rows.size();i++){       collections.sort(rows.get(i));     }     //showing each row(array)     for(int i=0;i<rows.size();i++){       system.out.println("kolon"+(i+1)+": "+rows.get(i));     }  }// main end   } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -