zoukankan      html  css  js  c++  java
  • Java_1Lesson

    cmd使用
    进入硬盘分区:D:  E:  F:
    查看目录 dir
    进入文件夹  “cd 文件名”
    .使用javac编译器编译运行。
      Javac 文件名
    运行java程序
    Java 文件名
    第一个程序
    public class hello
    {
        public static void main(String[] arg)
        {
            System.out.println("hello world");
        }
     
    }
    第二个程序
    public class hello
    {
        public static void main(String[] arg)
        {
            int s=0;
            for(int i=1;i<=100;++i)
                s+=i;
            System.out.println(s);
        }
     
    }
    第三个程序
    public class hello
    {
        public static void main(String[] arg)
        {
            int s=0;
            for(int i=1;i<=100;++i)
                s+=i;
            System.out.println(s);
        }
     
    }
    
    class A
    {}
    class B
    {}
    class C
    {}
    
    会生成四个文件。
    
    了解JVM运行过程
    JAVA 编程规范
    
    栈空间:引用变量、基本数据类型、int,float,short,double 默认值为随机的,并且会报错。
    堆空间:new分配堆空间,默为值为即NULL
    
    变量
    特性:
      名称:$,字母,下划线可作变量名发头,数字不可以作为开头。
      类型:
      初始值:
      作用域 :
    Java中两大数据类型:
    
    基本数据类型:byte,boolean,char,short,int,long,float,double
    byte:8位符号整数,boolean:bool类只有ture和flase
    引用数据类型:class interface 数组
    
    基本数据类型之间的转换:
    不同类型的变量运算,.........
    
    运算符:
    .................................
    Instanceof 是否是该类的对象。
    & 为双目运算,两边的类型必须要相同。
    >>> 无符号位移 
    
    第三个程序:
    public class hello
    {
        public static void main(String[] arg)
        {
            int i=1;
            switch(i)
            {
                case 1:System.out.println("A");break;
                case 2:System.out.println("B");break;
                case 3:System.out.println("C");break;
                default:System.out.println("D");break;
            }
        }
     
    }
    
    public class hello
    {
        public static void main(String[] arg)
        {
            int i=1;
            switch(i)
            {
                case 1:System.out.println("A");
                case 2:System.out.println("B");
                case 3:System.out.println("C");
                default:System.out.println("D");
            }
        }
     
    }
    
    第四个程序:
    public class hello
    {
        public static void main(String[] arg)
        {
            int x=10;
    
                if(x<1)
                    System.out.println(x);
                    else if(1<=x&&x<10) 
                        System.out.println(3*x-2);
                        else 
                            System.out.println(4*x);
                
            
        }
     
    }
    
    
    第五个程序:
    public class hello
    {
        public static void main(String[] arg)
        {
            int x=1;
    
            while(x<5)
            {    
                if(i==3)
                {
                    break;
                }
                ++i;
                System.out.println(x);
            }
                
            
        }
     
    }
    
    第六个程序:
    public class hello
    {
        public static void main(String[] arg)
        {
            int x=1;
    
            while(x<5)
            {    
                if(i==3)
                {
                    continue;        //进入死循环    
      }
                ++i;
                System.out.println(x);
            }
        }
     
    }
  • 相关阅读:
    PAT 1020 月饼 (25)(精简版代码+思路+推荐测试用例)
    PAT 1010 一元多项式求导 (25)(STL-map+思路)
    通过无线连接的方式来做 Appium 自动化
    Eclipse shift + ctrl + F 不好用
    Appium 出现 > error: com.test/.activity1 never started. Current: com.test/.activity2
    Appium 出现 > error: com.test/.activity1 never started. Current: com.test/.activity2
    从CSDN 来到博客园入驻——2015/1/28
    敏捷自动化测试(1)—— 我们的测试为什么不够敏捷?
    敏捷自动化测试(2)——像用户使用软件一样享受自动化测试
    Android自动化测试之Monkey工具
  • 原文地址:https://www.cnblogs.com/orangebook/p/3452706.html
Copyright © 2011-2022 走看看