提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
数字文字可以在Java中包含下划线字符(_)。
public class Main { /** * 时 代 J a v a - N o w J a v a . c o m 提 供 **/ public static void main(String[] args) { long debitCard = 1234_5678_9876_5432L; System.out.println("The card number is: " + debitCard); System.out.print("The formatted card number is:"); printFormatted(debitCard); float minAmount = 5_000F; float currentAmount = 5_250F; float withdrawalAmount = 500F; if ((currentAmount - withdrawalAmount) < minAmount) { System.out.println("Minimum amount limit exceeded " + minAmount); } } private static void printFormatted(long cardNumber) { String formattedNumber = Long.toString(cardNumber); for (int i = 0; i < formattedNumber.length(); i++) { if (i % 4 == 0) {