赞
踩
- package Test;
-
- public class Test{
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- student student1 = new student("李明",18,"本科");
- student1.show();
- undergraduate unstudent1 = new undergraduate("计算机");
- unstudent1.name = "李丽";
- unstudent1.age = 20;
- unstudent1.show();
- unstudent1.showb();
- graduate grastudent1 = new graduate("机器学习");
- grastudent1.name = "刘明";
- grastudent1.age = 24;
- grastudent1.show();
- grastudent1.showm();
-
- }
-
- }
-
- class student {
- String name;
- int age;
- String degree;
- student(){
- }
- student(String name,int age){
- this.name = name;
- this.age = age;
- }
- student(String name,int age,String degree){
- this.name = name;
- this.age = age;
- this.degree = degree;
- }
- void show(){
- System.out.println("学生信息为:");
- System.out.println("姓名:"+name);
- System.out.println("年龄:"+age);
- System.out.println("学位为:"+degree);
- }
- }
-
- class undergraduate extends student{
-
- String major;
- undergraduate(){
- degree = "bachelor";
- }
- undergraduate(String major){
- degree = "bachelor";
- this.major = major;
- }
- void showb(){
- System.out.println("专业为:"+major);
- }
- }
-
- class graduate extends student{
-
- String Research_Area;
- graduate(){
- degree = "master";
- }
- graduate(String Research_Area){
- degree = "master";
- this.Research_Area = Research_Area;
- }
- void showm(){
- System.out.println("研究方向为:"+Research_Area);
- }
- }
- public class Student {
-
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- student student1 = new student("李明",18,"本科");
- student1.show();
- undergraduate unstudent1 = new undergraduate("计算机");
- unstudent1.name = "李丽";
- unstudent1.age = 20;
- unstudent1.show();
- unstudent1.showb();
- graduate grastudent1 = new graduate("机器学习");
- grastudent1.name = "刘明";
- grastudent1.age = 24;
- grastudent1.show();
- grastudent1.showm();
- }
-
- }
-
- class student {
- String name;
- int age;
- String degree;
- student(){
- }
- student(String name,int age){
- this.name = name;
- this.age = age;
- }
- student(String name,int age,String degree){
- this.name = name;
- this.age = age;
- this.degree = degree;
- }
- void show(){
- System.out.println("学生信息为:");
- System.out.println("姓名:"+name);
- System.out.println("年龄:"+age);
- System.out.println("学位为:"+degree);
- }
- }
-
- class undergraduate extends student{
-
- String major;
- undergraduate(){
- degree = "bachelor";
- }
- undergraduate(String major){
- degree = "bachelor";
- this.major = major;
- }
- void showb(){
- System.out.println("专业为:"+major);
- }
- }
-
- class graduate extends student{
-
- String Research_Area;
- graduate(){
- degree = "master";
- }
- graduate(String Research_Area){
- degree = "master";
- this.Research_Area = Research_Area;
- }
- void showm(){
- System.out.println("研究方向为:"+Research_Area);
- }
- }
Exception in thread "main" java.lang.NoClassDefFoundError: Student (wrong name: student)
at java.lang.ClassLoader.defineClass1(Native Method)at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
尝试了很多发方法,终于找到一个方法:就是在该工程下新建一个包,修改类名Student为Test就能正常运行。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。