java实训日记Day2

行业情况与大厂经验:

面试的类型:面试一般分为技术面和hr面。技术面就是考验你的相关技术,hr面就是看你的个人综合素质和家庭状况符不符合公司要求。就算是有面试的技巧,也要基于有足够的专业水平才可以。

技术面的技巧:1.投简历的时候对于自己掌握的相关技能有一个适当的介绍。比如面试的是Java工程师,你就写精通java。了解python,熟悉C语言。这样他问的东西就会有侧重点。

代码学习:

1.单目运算:

public class Dan_mu_yunsuan {
    public static void main(String[] args) {
        int a = 2;
        int b = a++;
        System.out.println(b);
        int c = ++a;
        System.out.println(c);
    }
}

2.双目运算:

public class Yun_suan {
    public static void main(String[] args) {
        //加减乘除取余
        int a = 7;
        int b = 4;
        System.out.println(a+b);
        System.out.println(a-b);
        System.out.println(a*b);
        System.out.println(a/b);
        System.out.println(a%b);
    }
}

3.三目运算:

import java.util.Scanner;

/**
 * 使用三目运算符判断用户输入的整数是负数,正数还是零。
 */
public class San_mu_yunsuan {
    public static void main(String[] args) {
        System.out.println("请输入一个整数:");
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        String s = n>0?"正数":n==0?"零":"负数";
        System.out.println("你输入的是:"+s);
    }
}

4.Switch语句:

import java.util.Scanner;
/**
 * 提示用户输入业绩排名,判断去哪儿游玩
 */
public class SwitchDemo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的业绩排名:");
        int x = sc.nextInt();
        switch (x){
            case 1:
                System.out.println("欧洲游");
                break;
            case 2:
                System.out.println("亚洲游");
                break;
            case 3:
                System.out.println("国内游");
                break;
            case 4:
                System.out.println("省内游");
                break;
            default:
                System.out.println("游什么游,加班!!");
                break;
        }
    }
}

import java.util.Scanner;
/**
 * 提示用户输入月份,判断该月的天数,不考虑闰年
 */
public class SwitchDemo2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入月份:");
        int m = sc.nextInt();
        switch (m){
            case 2 :
                System.out.println("当月有28天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println("当月有30天");
                break;
            default:
                System.out.println("当月有31天");
                break;
        }
    }
}

5.for循环语句

/**
 * 打印1-100之间的偶数
 */
public class ForDemo {
    public static void main(String[] args) {
        for(int i = 1;i<=100;i++){
            if(i%2==0){
                System.out.println(i+" ");
            }
        }
    }
}

6.if语句

import java.util.Scanner;
/**
 * 使用if分支结构,提示用户输入两个数,求最大值
 */
public class IfDemo {
    public static void main(String[] args) {
        System.out.println("请输入两个整数:");
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int max = a;
        if(a < b){
            max = b;
        }
        System.out.println("最大值为:"+ max);
    }
}

7.if-else语句

import java.util.Scanner;
/**
 * 使用if—else分支语句,判断输入的整数的正负。
 */
public class IfElseDemo {
    public static void main(String[] args) {
        System.out.println("输入一个非零整数:");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n>0){
            System.out.println("该数为正数");
        }else{
            System.out.println("该数为负数");
        }
    }
}

8.else if语句

import java.util.Scanner;
/**
 * 提示用户输入身份信息进行购票,判断身份信息是军人,学生,还是普通人。
 */
public class ElseIfDemo {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("输入你的身份信息(军人,学生,普通人):");
        String shenfen = sc.next();
        if(shenfen.equals("军人")){
            System.out.println("由于您是军人,享受免票");
        }else if (shenfen.equals("学生")){
            System.out.println("由于您是学生,享受半价购票");
        }else {
            System.out.println("您啥也不是,请购买全票");
        }
    }
}

9.双重for循环

/**
 * 打印九九乘法表
 */
public class DoubleForDemo {
    public static void main(String[] args) {
        for(int i = 1;i < 10;i++){
            for(int j = 1;j <= i;j++){
                System.out.printf("%d * %d = %d  ",i,j,i*j);
            }
            System.out.println();
        }
    }
}

10.while循环语句

import java.util.Scanner;
/**
 *跑圈 跑完一圈提示用户是否还能跑,如果不能则结束
 */
public class WhileDemo {
    public static void main(String[] args) {
        int i = 1;
        Scanner sc = new Scanner(System.in);
        while (true){
            System.out.println("你已经跑了"+i+"圈,是否要继续跑");
            String s = sc.next();
            if(s.equals("否")){
                System.out.println("不行了,跑不动了");
                break;
            }else if (s.equals("是")){
                System.out.println("接着跑,加油!");
                i++;
            }
        }
    }
}

11.do-while循环语句

public class DoWhileDemo {
    public static void main(String[] args) {
        int i = 1;
        //do-while语句会先执行一次,再看循环条件是否满足
        do {
            System.out.println(i+" ");
            i++;
        }while (i <= 0);
    }
}

  • 17
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值