zoukankan      html  css  js  c++  java
  • 2020.8.20第四十五天

    例8.1类的简单例子

     1 public class cjava {
     2     public static void main(String[] args) {
     3         Time t = new Time();
     4         Scanner s=new Scanner(System.in);
     5         t.hour=s.nextInt();
     6         t.minute=s.nextInt();
     7         t.sec=s.nextInt();
     8         System.out.println(t.hour+":"+t.minute+":"+t.sec);
     9 }
    10 }
    11 class Time{
    12     int hour;
    13     int minute;
    14     int sec;
    15 }

    例8.2引用多个对象成员

     1 public class cjava {
     2     public static void main(String[] args) {
     3         Time t1 = new Time();
     4         Scanner s=new Scanner(System.in);
     5         t1.hour=s.nextInt();
     6         t1.minute=s.nextInt();
     7         t1.sec=s.nextInt();
     8         System.out.println(t1.hour+":"+t1.minute+":"+t1.sec);
     9         Time t2=new Time();
    10         t2.hour=s.nextInt();
    11         t2.minute=s.nextInt();
    12         t2.sec=s.nextInt();
    13         System.out.println(t2.hour+":"+t2.minute+":"+t2.sec);
    14 }
    15 }
    16 class Time{
    17     int hour;
    18     int minute;
    19     int sec;
    20 }

     2.遇到的问题:无

    3.明天继续写例题

  • 相关阅读:
    创建github怎样管理
    端口号的作用
    正则
    分布式代码管理github
    实现MVC
    AngularJS核心特性(四大点)
    什么是跨域,什么是同源
    rem怎么计算
    正则须知(以后还会添加)
    LA 6448 Credit Card Payment
  • 原文地址:https://www.cnblogs.com/Nojava/p/13537651.html
Copyright © 2011-2022 走看看