我是靠谱客的博主 大胆柜子,最近开发中收集的这篇文章主要介绍java参数错误_java参数不对怎么弄,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

//Abytecan'tholdavaluehigherthan127//ThisprogramthrowsanArithmeticException//ifaddingtwobytesyieldsavaluethatistoohighpublicclassDebugTwelve2{publicstaticvoidmain(String[...

// A byte can't hold a value higher than 127

// This program throws an ArithmeticException

// if adding two bytes yields a value that is too high

public class DebugTwelve2

{

public static void main(String[] args)

{

byte num1 = 120, num2 = 120, result;

final byte HIGHBYTE = 127;

try

{

allowed = (byte)(HIGHBYTE - num1);

if(num2 > allowed)

throw(new ArithmeticException);

result = (byte)(num1 + num2);

System.out.println("Result is " + result);

}

catch(ArithmeticException error)

{

System.out.println(Byte can't hold value higher than + HIGHBYTE);

}

}

}

---------- compiler ----------

DebugTwelve2.java:14: 错误: 需要'('或'['

throw(new ArithmeticException);

^

DebugTwelve2.java:20: 错误: 需要')'

System.out.println(Byte can't hold value higher than + HIGHBYTE);

^

DebugTwelve2.java:20: 错误: 未结束的字符文字

System.out.println(Byte can't hold value higher than + HIGHBYTE);

^

DebugTwelve2.java:20: 错误: 需要';'

System.out.println(Byte can't hold value higher than + HIGHBYTE);

^

DebugTwelve2.java:20: 错误: 需要';'

System.out.println(Byte can't hold value higher than + HIGHBYTE);

^

DebugTwelve2.java:20: 错误: 不是语句

System.out.println(Byte can't hold value higher than + HIGHBYTE);

^

DebugTwelve2.java:20: 错误: 需要';'

System.out.println(Byte can't hold value higher than + HIGHBYTE);

^

7 个错误

输出完成 (耗时 2 秒) - 正常终止

展开

最后

以上就是大胆柜子为你收集整理的java参数错误_java参数不对怎么弄的全部内容,希望文章能够帮你解决java参数错误_java参数不对怎么弄所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部