Java - ¿Por qué sucede esto? [en espera
i he escrito esta clase para almacenar e imprimir los detalles del alumno para una tarea. a continuación está mi código junto con el error que recibo cuando intento compilar mi código.
este es mi código:
import java.util.*;
public class Student
{
private String forName;
private String surName;
private String studentID;
private String degreeScheme;
//This is the Constructor of the class Student
public forName(String name) {
this.name = forName;
}
//Assign the surname of the student
public void stuSurname (String stuSurname){
surName = stuSurname;
}
//Assign the student ID to the student
public void stuID (String stuID){
studentID = stuID;
}
//Assign the Degree of the Student
public void stuDegree (String stuDegree){
degreeScheme = stuDegree;
}
//Print the student details
public void printStudent(){
System.out.println("Forname:"+ name);
System.out.println("Surename:"+
stuSurname);
System.out.println("Student ID:"+ stuID);
System.out.println("Degree Scheme:"+
stuDegree);
}
}
Este es el error que obtengo:
TheRealFawcett:lab8 javac
Student.java
Student.java:11: error: invalid method
declaration; return type required
public forName(String name) {
^
Edit: no he solucionado el error en el mensaje anterior, sin embargo, ahora tengo un nuevo error.
TheRealFawcett:lab8 therealfawcett$ java Student
Error: Main method not found in class Student, please define the main
method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
TheRealFawcett:lab8 therealfawcett$