zoukankan      html  css  js  c++  java
  • 定义类

    1、面向对象编程(oop)内容总结

    2、编码实现定义类

    package com.hanqi;
    
    public class Shouji 
    {
        //属性  成员变量
        
        String Color;
        
        double Chicun;
        
        int  Weight;
        
        //行为  用方法表示
        
        void dadianhua()
        {
            System.out.println("我能打电话");
        }    
        void shangwang()
        {
            System.out.println("我能上网");
        }
        public static void main(String[] args)
        {
            //生成一个手机的实例  金色,5.5英寸,172克
            
            Shouji  iPhone = new Shouji();
            
            iPhone.Color="金色";
            
            iPhone.Chicun=5.5;
            
            iPhone.Weight=172;
            
            System.out.println("苹果 iPhone 6 Plus 颜色"  +iPhone.Color);
            
            System.out.println("苹果 iPhone 6 Plus 尺寸"  +iPhone.Chicun);
            
            System.out.println("苹果 iPhone 6 Plus 重量"  +iPhone.Weight);
            
            iPhone.dadianhua();
            
            iPhone.shangwang();    
        }
    }
    定义类

  • 相关阅读:
    Day10
    Day9
    Day8
    Day 7
    Day-6
    java中的原子性
    java 原子性
    内存可见性
    JVM 常忘笔记
    JVM 解释执行 编译执行 JIT
  • 原文地址:https://www.cnblogs.com/wangchuanqi/p/5235547.html
Copyright © 2011-2022 走看看