mình có viết một đoạn code thế này, nhưng khi cho in ra kết qua những người có họ tương ứng thì chỉ in được họ, không in được tên đầy đủ, có thành nào cứu với!


Mã nguồn PHP:
[color=#000000]
[/color][color=#007700]public class [/color][color=#0000bb]study [/color][color=#007700]{ public static [/color][color=#0000bb]void main[/color][color=#007700]([/color][color=#0000bb]string[/color][color=#007700][] [/color][color=#0000bb]args[/color][color=#007700]) { [/color][color=#0000bb]scanner input [/color][color=#007700]= new [/color][color=#0000bb]scanner[/color][color=#007700]([/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]in[/color][color=#007700]); [/color][color=#0000bb]string [/color][color=#007700][] [/color][color=#0000bb]hocsinh [/color][color=#007700]= new [/color][color=#0000bb]string[/color][color=#007700][[/color][color=#0000bb]100[/color][color=#007700]] ; [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập số học sinh: "[/color][color=#007700]); [/color][color=#0000bb]int n[/color][color=#007700]=[/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextint[/color][color=#007700](); for ([/color][color=#0000bb]int i[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]<[/color][color=#0000bb]n[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập học sinh thứ "[/color][color=#007700]+([/color][color=#0000bb]i[/color][color=#007700]+[/color][color=#0000bb]1[/color][color=#007700])+[/color][color=#dd0000]": "[/color][color=#007700]); [/color][color=#0000bb]hocsinh[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]] = [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]next[/color][color=#007700](); [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); } [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].print([/color][color=#dd0000]"nhập họ muốn tìm: "[/color][color=#007700]); [/color][color=#0000bb]string ho [/color][color=#007700]= [/color][color=#0000bb]input[/color][color=#007700].[/color][color=#0000bb]nextline[/color][color=#007700](); [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#dd0000]"những người có họ " [/color][color=#007700]+ [/color][color=#0000bb]ho [/color][color=#007700]+ [/color][color=#dd0000]": "[/color][color=#007700]); for ([/color][color=#0000bb]int i[/color][color=#007700]=[/color][color=#0000bb]0[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]<[/color][color=#0000bb]n[/color][color=#007700]; [/color][color=#0000bb]i[/color][color=#007700]++){ if([/color][color=#0000bb]hocsinh[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]].[/color][color=#0000bb]substring[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], ([/color][color=#0000bb]ho[/color][color=#007700].[/color][color=#0000bb]length[/color][color=#007700]())).[/color][color=#0000bb]equals[/color][color=#007700]([/color][color=#0000bb]ho[/color][color=#007700])){ [/color][color=#0000bb]system[/color][color=#007700].[/color][color=#0000bb]out[/color][color=#007700].[/color][color=#0000bb]println[/color][color=#007700]([/color][color=#0000bb]hocsinh[/color][color=#007700][[/color][color=#0000bb]i[/color][color=#007700]]+[/color][color=#dd0000]" "[/color][color=#007700]); } } } }[/color]