W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
public class Main {
  public static void main(String[] args) {
    // 创建不同数据类型的变量
    int items = 50;
    float costPerItem = 9.99f;
    float totalCost = items * costPerItem;
    char currency = '$';
​
    // 打印变量
    System.out.println("商品数量: " + items);
    System.out.println("单价: " + costPerItem + currency);
    System.out.println("总价 = " + totalCost + currency);
  }
}