Note that there are some explanatory texts on larger screens.

plurals
  1. POArray become empty after it filled
    text
    copied!<p>I have a terrible problem in my code. I use this code to compare Arabic characters, every thing is fine in the comparison. I also use an array called numbers to store some statistic numbers within it and every thing is fine too. But the problem is when I use the array numbers to get the max from it I found the array entries zeros, not that numbers it actually filled . Besides I sent the code to a friend he told me that the debugger never reach to array numbers and it filled zeros, but in my Eclipse every thing is fine except when I reuse the array numbers again in my code I found it zeros. What is my error? Please some one help me. </p> <p>I don't know how to send my code. </p> <pre><code>public static float[][] numbers; public static float myarray[][]; public static float sum = (float) 0.0; public static float max=(float) 0.0; public static int topicnumber = 0; public static void resultTesting(String filename) throws IOException { File modal=new File("C:\\Users\\Monjed\\workspace\\Classification_Docc\\model-00010.twords"); Scanner fromFileName=new Scanner(new File(filename)); Scanner fromModel=new Scanner(modal); numbers=new float[3000][6]; myarray=new float[3000][6]; for(int c=0;c&lt;6;c++) { for(int r=0;r&lt;3000;r++) { numbers[r][c]=0; myarray[r][c]=0; } } int i=0; int a=0; String word=""; if(fromModel.hasNext()) { word=fromFileName.next(); } while(fromFileName.hasNext()) { i=0; while(fromModel.hasNext()) { a=0; String myWord=fromModel.nextLine(); while(!myWord.contains("Top")) { myWord=myWord.replaceAll("\\\\$|\\\\^", ""); String[] split=myWord.split(" "); byte s[]=split[0].getBytes(); split[0]=new String(s, "UTF-8"); split[0]=myTrim(split[0]); split[0]=split[0].trim(); word=myTrim(word); word=word.trim(); word=word.replaceAll("$\\\\|^\\\\", ""); split[0]=split[0].replaceAll("$\\\\|^\\\\", ""); word=word.replace("؟", ""); word=word.replace("،", ""); word=word.replace("-", ""); word=word.replace(".", ""); split[0]=split[0].replace("؟", ""); split[0]=split[0].replace("،", ""); split[0]=split[0].replace("-", ""); split[0]=split[0].replace(".", ""); if(split[0].equals(word)) { numbers[a][i]=Float.parseFloat(split[1].toString()); fillthearray(a, i,numbers[a][i] ); a++; } if(fromModel.hasNext()) { myWord=fromModel.nextLine(); } else break; } if(i&lt;5) i++; else break; } if(fromFileName.hasNext()) { fromModel=new Scanner(modal); word=fromFileName.next(); i=0; a=0; } else break; } JOptionPane.showMessageDialog(null,printarrayresult(myarray)," النتيجه هي ",JOptionPane.YES_OPTION); } private static String myTrim(String mystring) { char x[]=mystring.toCharArray(); char y[]=new char[x.length]; String str=""; for(int i=0;i&lt;x.length;i++) { byte a=(byte)x[i]; if(a&lt;0x0600&amp;&amp;a&gt;0x06ff) { continue; } else y[i]=x[i]; } for(int j=0;j&lt;y.length;j++) str+=y[j]; return str; } public static void fillthearray(int x,int y,float i) { myarray[x][y]=i; // System.out.println(myarray[x][y]); } private static String printarrayresult(float data[][]) { for(int i=0;i&lt;6;i++) for(int j=0;j&lt;3000;j++) { data[j][i]=myarray[j][i]; System.out.println(myarray[j][i]); } for(int y=0;y&lt;1;y++) { for(int w=0;w&lt;3000;w++) { //System.out.println(myarray[w][y]); sum+=myarray[w][y]; } } max=sum; for(int x=0;x&lt;6;x++) { sum=0; int y=0; for( y=0;y&lt;3000;y++) { sum+=myarray[y][x]; //System.out.println(sum+" "+max); } //System.out.println(myarray[y-1][x]); if(sum&gt;max) { //System.out.println(sum); max=sum; topicnumber++; } } if(topicnumber==0) { return "اعمال"; } if(topicnumber==1) return "اقتصاد"; if(topicnumber==2) { return "رياضه"; } if(topicnumber==3) { return "سياسه"; } return "علوم"; } </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