我是靠谱客的博主 活力篮球,这篇文章主要介绍类名大写,现在分享给大家,希望可以做个参考。

     第一、类名要大写(Test);

     第二、可以有多个类,但是只能一个是public。

import java.util.*;
public class Test
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
double oblength,obheight;
Oblong myoblong;
System.out.print("please enter the length");
oblength = sc.nextDouble();
System.out.print("please enter the height");
obheight = sc.nextDouble();
myoblong = new Oblong(oblength,obheight);
System.out.println("length="+myoblong.getLength());
System.out.println("height="+myoblong.getHeight());
System.out.println("area="+myoblong.calculateArea());
System.out.println("perimeter="+myoblong.calculatePerimeter());
}
}
class Oblong
{
private double length;
private double height;
public Oblong(double a,double b)
{
length = a;
height = b;
}
public double getLength()
{
return length;
}
public double getHeight()
{
return height;
}
public double calculateArea()
{
return length * height;
}
public double calculatePerimeter()
{
return 2*(length + height);
}
}

 

转载于:https://www.cnblogs.com/HpuAcmer/archive/2012/03/03/2378454.html

最后

以上就是活力篮球最近收集整理的关于类名大写的全部内容,更多相关类名大写内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(124)

评论列表共有 0 条评论

立即
投稿
返回
顶部