java报错出现未知源_java - 未知格式转换异常运行时错误 - 堆栈内存溢出

我编写了一个程序,用户输入3个4位十六进制数字,然后使用String方法按大小对它们进行排序。 我遇到了一个我不熟悉的错误。 系统会编译,但会运行并显示错误。 我将发布我的源代码和错误

import java.util.Scanner;

public class HexNumbers {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Enter three 4-digit hexadecimal numbers: ");

String numbers = input.nextLine();

String[] result = numbers.split("\\s+");

String a = result[0];

String b = result[1];

String c = result[2];

String A = a.toUpperCase();

String B = b.toUpperCase();

String C = c.toUpperCase();

int comp1 = C.compareTo(A);

int comp2 = C.compareTo(B);

int comp3 = B.compareTo(A);

boolean first = comp2 > comp1 && comp1 > 0 && comp2 > 0;

boolean second = comp1 <0 && comp2 < 0 && comp2 > comp1;

boolean third = comp1 > 0 && comp2 > 0 && comp1 == comp2;

boolean fourth = comp1 < 0 && comp2 < 0 && comp1 == comp2;

if(first = true){

System.out.printf("Maximum: %/s /n Median: %/s /n Minimum: %/s /n", C, A, B);

}

else if (second = true) {

System.out.printf("Maximum: %/s /n Median: %/s /n Minimum: %/s /n", A, B, C);

}

else if (third = true) {

if (comp3 > 0){

System.out.printf("Maximum: %/s /n Median: %/s /n Minimum: %/s /n", C, B, A);

}

else{

System.out.printf("Maximum: %/s /n Median: %/s /n Minimum: %/s /n", C, A, B);

}

}

else if (fourth = true) {

if (comp3 > 0){

System.out.printf("Maximum: %/s /n Median: %/s /n Minimum: %/s /n", B, A , C);

}

else{

System.out.printf("Maximum: %/s /n Median: %/s /n Minimum: %/s /n", A, B, C);

}

}

}

}

这是用户输入字符串后出现的错误:

java.util.UnknownFormatConversionException: Conversion = '/'

at java.util.Formatter.checkText(Unknown Source)

at java.util.Formatter.parse(Unknown Source)

at java.util.Formatter.format(Unknown Source)

at java.io.PrintStream.format(Unknown Source)

at java.io.PrintStream.printf(Unknown Source)

at HexNumbers.main(HexNumbers.java:33)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:267)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值