第二周总结

学习内容总结

基础

  1. JDK的配置。
  2. 一个文件中只能有一个主类名(public class),必须跟文件名一致。使用class定义的类,生成的*.class文件名就是class定义的类名称。
  3. 注释方法:
  • //·········
  • /········/
  • /**·······*/ javadoc注释(编译时自动生成帮助文档)
  1. 标识符:
  • 不能以数字开头;
  • 不能是Java中的保留关键字;
  • 区分大小写:类名首字母大写,常量全部大写,变量全部小写;
  • 变量名尽可能有意义;
  1. 数据类型
  2. 运算符

!!!重点:

& 与:两真为真 && 短路与:若前面一个为假,则不判断后一个,判定为假。
| 或:一真为真 || 短路或:若前面一个为真,则不判断后一个,判定为真。

程序语句

  1. if语句
  2. if··else语句
  3. if···else嵌套语句
  4. switch 语句
  5. while循环语句
  6. for循环语句

个人总结

hello.java

public class hello {
    public static void main (String[] args) {
        System.out.println("Hello World");
    }
}
编译结果:

test.java

public class test {
  public static void main(String args[]){
      System.out.println("***************************");
      System.out.print("*******");
      System.out.print("Java程序设计");
      System.out.println("*******");
      System.out.println("***************************");
    }
}
编译结果:

main.java(判断闰年)

import java.util.Scanner;
public class main {
public static void main(String args[]) {
	int year=0;
 
	Scanner reader = new Scanner(System.in);
	year = reader.nextInt();
    if(year/400==0)
    {
    	System.out.println("yes");
    }
    else if((year/4)==0&&(year/100)!=0)
    {
    	System.out.println("yes");
    }
    	
    else
    {
    	System.out.printf("no");
    }
	    
}
}
编译结果

遇到的问题:


解决后:

问题:混淆了%和/的用法,导致程序中数值的出错。

目前的疑惑:空心字母金字塔

package yyy;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		System.out.print("请输入一个大写字母:");
		 char a=sc.next().charAt(0);
		 int c=a-65;
		 System.out.println("组成的金字塔是:");
		for(int i=0;i<=c;i++)
		{
			for(int j=c-1-i;j>=0;j--)
			{
				System.out.print(" ");
			}
			for(char k='A';k<=i+'A';k++)
			{
				System.out.print(k);
			}		
			for(int m='A'+i-1;m>='A';m--)
			{
				char t=(char)m;
		     	System.out.print(t);
			}
				System.out.println();
		}
	}
}

感受

我太难了啊.....java太难了啊.....

感觉大二的时间完全不够呀,事情很多,想要学会的东西更多。一天的时间都耗在电脑前。看剧刷视频的时间用来学习其实是一个很好的改变,加油!!!!

posted @ 2019-09-07 16:32  颜晴超甜♡  阅读(136)  评论(0编辑  收藏  举报