博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
int_Keyword
阅读量:3924 次
发布时间:2019-05-23

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

int Java Keyword with Examples

Key points about int Keyword

  • The int keyword is used to declare a variable as a numeric type. For example, int a = 10;
  • A int variable is a signed 32-bit type that has a range from –2,147,483,648 to 2,147,483,647.
  • The Integer class is a wrapper class for the int primitive type. It defines MIN_VALUE and MAX_VALUE constants representing the range of values for this type.

In the following example, the sum, i and n variables are of type int:

package net.javaguides.corejava.variables;public class LocalVariableExample {    public int sum(int n) {        int sum = 0;        for (int i = 0; i < n; i++) {            sum = sum + i;        }        return sum;    }    public static void main(String[] args) {        LocalVariableExample localVariableExample = new LocalVariableExample();        int sum = localVariableExample.sum(10);        System.out.println("Sum of first 10 numbers -> " + sum);    }}

Output:

Sum of first 10 numbers -> 45

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

你可能感兴趣的文章
IdentityServer4系列 | 简化模式
查看>>
小试YARP
查看>>
如何使用 C# 中的 HashSet
查看>>
api-hook,更轻量的接口测试工具
查看>>
一个情怀引发的生产事故(续)
查看>>
如何在 C# 中使用 RabbitMQ
查看>>
一套标准的ASP.NET Core容器化应用日志收集分析方案
查看>>
如何使用 C# 扩展方法
查看>>
C#如何回到主线程,如何在委托指定线程执行
查看>>
服务器重新部署踩坑记
查看>>
.NET应用程序安全操作概述
查看>>
C# WPF:把文件给我拖进来!!!
查看>>
生态和能力是国内自研操作系统发展的关键
查看>>
银河麒麟V10入选2020中国十大科技新闻
查看>>
Amazing 2020
查看>>
代码改变世界,也改变了我
查看>>
2021,未来可期
查看>>
阿星Plus:基于abp vNext开源一个博客网站
查看>>
写给自己,2020的年终总结
查看>>
Flash 生命终止,HTML5能否完美替代?
查看>>