zoukankan      html  css  js  c++  java
  • java学习50天2020/8/24

    import java.util.Scanner;
    public class Rectangle {
        private int length; //矩形的长
        private int width;  //矩形的宽
         public Rectangle() {
         }
         public Rectangle(int length, int width) {
            this.length = length;
             this.width = width;
        }
         public void area() {
             int s;
             s=length*width;
             System.out.println("矩形面积:"+s);
         }
         public static void main(String[] args) {
             Scanner in=new Scanner(System.in);
             int a,b;
             System.out.print("请输入矩形的长和宽:");
             a=in.nextInt();
             b=in.nextInt();
             Rectangle r=new Rectangle(a,b);
             r.area();
         }
     }
    

     

    public class DataType {
        private char s; 
        private int a;   
        private double b; 
        public DataType() {
        }
         public DataType(char s, int a, double d) {
             this.s = s;
             this.a = a;
            this.b = d;
         }
         public void display() {
             System.out.println("字符型:"+s);
            System.out.println("整型:"+a);
             System.out.println("浮点型:"+b);
         }
         public static void main(String[] args) {
             DataType p=new DataType('s',5,5.2);
             p.display();
         }
     }
    

     

    三.例题

  • 相关阅读:
    密码等级
    ie兼容透明
    分割线
    支付宝银行判断接口
    date只能选择今天之后的时间js
    离开页面之前提示,关闭,刷新等
    使用 Linux 系统的常用命令
    C#窗体简单增删改查
    1
    二维数组
  • 原文地址:https://www.cnblogs.com/qiangini/p/13583406.html
Copyright © 2011-2022 走看看