本文共 970 字,大约阅读时间需要 3 分钟。
Key points about int Keyword
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/