求助大佬,下面的代码为什么超时?
package com.lanq;
import java.beans.DesignMode;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
//3位十六进制相当于4位八进制
public static void main(String[] args) {
int n = sc.nextInt();
while( n-- > 0){
String str = sc.next();
char[] ch = str.toCharArray();
int length = str.length();
String otc = "";
for(int i=0; i<length; i+=3) {
String temp1 = "";
if( (i+3) >= length) {
for(int j=i ;j<length; j++) {
temp1 += ch[j];
}
}else {
temp1 += ch[i];
temp1 += ch[i+1];
temp1 += ch[i+2];
}
int temp2 = Integer.parseInt(temp1, 16);
String temp3 = Integer.toOctalString(temp2);
otc += temp3;
}
System.out.println(otc);
}
}
}