博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java BigInteger类| max()方法与示例
阅读量:2537 次
发布时间:2019-05-11

本文共 1873 字,大约阅读时间需要 6 分钟。

BigInteger类max()方法 (BigInteger Class max() method)

  • max() method is available in java.math package.

    max()方法在java.math包中可用。

  • max() method is used to get the highest value from both of the compared objects (this BigInteger and BigInteger val).

    max()方法用于从两个比较对象(此BigInteger和BigInteger val)获得最大值

  • max() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    max()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • max() method does not throw an exception at the time of returning maximum.

    max()方法在返回最大值时不会引发异常。

Syntax:

句法:

public BigInteger max(BigInteger val);

Parameter(s):

参数:

  • BigInteger val – represents the object to compare with this object for finding maximum.

    BigInteger val –表示要与该对象进行比较以找到最大值的对象。

Return value:

返回值:

The return type of this method is BigInteger, it returns the maximum in anyone of the both compared objects.

此方法的返回类型为BigInteger ,它返回两个比较对象中任何一个的最大值。

Example:

例:

// Java program to demonstrate the example // of BigInteger max(BigInteger val) method of BigIntegerimport java.math.*;public class MaxOfBI {
public static void main(String args[]) {
// Initialize two variables str1 and str2 String str1 = "100"; String str2 = "80"; // Initialize two BigInteger objects BigInteger b_int1 = new BigInteger(str1); BigInteger b_int2 = new BigInteger(str2); // Display b_int1 and b_int2 System.out.println("b_int1: " + b_int1); System.out.println("b_int2: " + b_int2); // returns the BigInteger that holds the maximum // value in both of the compared object // i.e. 100.max(80) it returns 100 BigInteger max_val = b_int1.max(b_int2); System.out.println("b_int1.max(b_int2): " + max_val); }}

Output

输出量

b_int1: 100b_int2: 80b_int1.max(b_int2): 100

翻译自:

转载地址:http://mivzd.baihongyu.com/

你可能感兴趣的文章
tomcat 7服务器跨域问题解决
查看>>
前台实现ajax 需注意的地方
查看>>
Jenkins安装配置
查看>>
个人工作总结05(第二阶段)
查看>>
Java clone() 浅拷贝 深拷贝
查看>>
深入理解Java虚拟机&运行时数据区
查看>>
STUCTS LABLE ‘S BENEFIT
查看>>
Vue 计算属性
查看>>
第十八次ScrumMeeting博客
查看>>
洛谷P2580 于是他错误的点名开始了 题解
查看>>
02-环境搭建
查看>>
spring第二冲刺阶段第七天
查看>>
搜索框键盘抬起事件2
查看>>
阿里百川SDK初始化失败 错误码是203
查看>>
透析Java本质-谁创建了对象,this是什么
查看>>
BFS和DFS的java实现
查看>>
QQ是怎样实现好友桌面快捷方式的?
查看>>
hadoop之安装
查看>>
Xamarin.Android开发实践(六)
查看>>
物联网项目的思考
查看>>