Java自学第一天

2020.3.2
今天准备开始写博客,
来记录一些自己掌握的知识点(听说这有利于自学)
开头先问
求大佬解惑:
System.out.println();
为什么会有很多类的println
public static void main(String[] args) 和package hello;
有什么作用

  1. public class happy
    有public的类,那么源文件明要和class 后的名称相同
    happy.java 才能运行源文件

  2. 符号比较
    6 > 5 > 4 true和4不能进行比较
    a == b == c true和c不能进行比较
    a == b > false true 和false没有大小差别

  3. 基本输入输出
    输入框架:
    Scanner in = new Scanner(System.in);
    int amount;
    amount = in.nextInt();
    输出框架:
    System.out.println( "找你: "+(amount-9));

  4. 浮点误差
    double a = 1.0;
    double b = 0.1 +0.1 +0.1 +0.1 +0.1 +0.1 +0.1 +0.1 +0.1 +0.1
    a!=b
    但可以用(Math.abs(a-b)<1e-6 来比较

  5. 判断
    if()
    {
    }
    这和c差不多 =-=

  6. 个人摸索 循环应该也就 for while do while

  7. 断点debug
    在这里插入图片描述
    四种方法来帮助找bug
    在这里插入图片描述
    返回Java

今日代码

package hello;

import java.util.Scanner;

public class Main
{

	public static void main(String[] args) {
		//初始化
		Scanner in = new Scanner(System.in);
		//请投币
	for(int i=0;i<10;i++){
		int amount;
		System.out.print("请输入金额:");
		amount = in.nextInt();
		if(amount>=9){
		//框架
		System.out.println("************");
		System.out.println("  环城一日游");
		System.out.println("  票价9块!");
		System.out.println("************");
		//处理输出
		System.out.println( "找你: "+(amount-9));
		}
		else
		{
			System .out .println("对不起,你的金额有限!");
		}
	}
	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值