我正在尝试将字符串解析为整数,但我得到不兼容的类型。我的计数器是针对文件中的记录数量,程序可以附加到文件并从中读取。现在我想对其进行排序并将其写回文件。我该如何执行此任务?此处未声明的变量是全局声明的。
public static void sort_addresses() throws IOException
{
String tnumber;
String tname;
String tnrooms;
int[] tmprooms;
int[] tmprooms1;
int j;
for (int i = 0; i < counter; i++)
{
for(j = 1; j < (counter-1); j++)
//while (street_name[counter] != null)
{
tmprooms = Integer.parseInt (number_rooms[counter]);
tmprooms1 = Integer.parseInt (number_rooms[counter+1]);
if (tmprooms[i] > tmprooms1[i+1])
{
tnumber = street_number[counter];
tname = street_name[counter];
tnrooms = number_rooms[counter];
street_number[counter] = street_number[counter +1];
street_name[counter] = street_name[counter+1];
number_rooms[counter] = number_rooms[counter+1];
number_rooms[counter+1] = tnumber ;
street_name[counter+1] = tname;
number_rooms[counter+1] = tnrooms;
System.out.println(street_number[i]+"\t"+street_name[i]
+"\t"+number_rooms[i]);
}
}