Arrayindexoutofboundsexception là gì

File trr.txt chứa file Source của chương trình

package BT2; import java.io.*; import java.util.*; import javax.swing.JOptionPane; class TRR2 { public static void main[String args[]] { File file = new File["D:\\test.txt"]; try { FileReader fr = new FileReader[file]; BufferedReader br = new BufferedReader[fr]; String line = br.readLine[]; int n = Integer.parseInt[line]; JOptionPane.showConfirmDialog[null, "Số lượng cặp đôi: \n" + line]; // Ma trận 1 String dong1 = br.readLine[]; int[][] a = new int[n][n]; for [int i = 0; i < n; i++] { String[] s = br.readLine[].split[" "]; for [int j = 0; j < n; j++] { int s_ = Integer.parseInt[s[j]]; a[i][j] = s_; } } // ma trân 2 String dong2 = br.readLine[]; int[][] b = new int[100][100]; for [int i = 0; i < n; i++] { String[] s = br.readLine[].split[" "]; for [int j = 0; j < n; j++] { int s_ = Integer.parseInt[s[j]]; b[i][j] = s_; } } // Ma trận 1 String xau1 = ""; for [int i = 0; i < n; i++] { String xau2 = ""; for [int j = 0; j < n; j++] { xau2 = xau2 + a[i][j] + " "; } xau1 = xau1 + xau2 + "\n"; } JOptionPane.showConfirmDialog[null, "Yêu thích của Nam: \n" + xau1]; // Ma trận 2 String xau3 = ""; for [int i = 0; i < n; i++] { String xau4 = ""; for [int j = 0; j < n; j++] { xau4 = xau4 + b[i][j] + " "; } xau3 = xau3 + xau4 + "\n"; } JOptionPane.showConfirmDialog[null, "Yêu thích của Nữ: \n" + xau3]; //Thuật toán kiểm tra int s, w, t; int[] next = new int[n]; int[] honphu = new int[n]; for [int i = 0; i < n; i++] { next[i] = 0; b[i][0] = n + 1; honphu[i] = 0; } for [int m = 1; m < n; m++] { s = m; do { next[s] = next[s] + 1; w = a[s][next[s]]; if [b[w][s] javac -g:none -d .\classes TRR.java D:\Test>java TRR Ghep doi 0 0 1 0 2 4 3 2 4 0 D:\Test>

I'm not sure about your result. From //katatunix.wordpress.com/2008/09/14/bai-toan-hon-nhan-bền-vững/ I see the result is :

WED.OUT 1 1 2 5 3 4 4 2

5 3

Thuannd,
you seem not to understand what I mean and who I am. But it's OK. BTW, don't teach an old man like me how to run java when he was at the beginning of JAVA genesis

. Furthermore I wrote:

I don't know what purpose this program is but what the link shows is either PASCAL or PL1....The rule is very simple: If I speak Java I think Java. If I speak Pascal I think Pascal... same for human language.

I don't care about the result. It's irrelevant. I just show the boy how to think like a developer and show him why and where the OutOfBoundaryException came from.

Video liên quan

Chủ Đề