Java - Por que isso acontece? [em espera
eu escrevi esta classe para armazenar e imprimir os detalhes do aluno para uma tarefa. abaixo está o meu código, juntamente com o erro que recebo quando tento compilar meu código.
Este é o meu 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 é o erro que recebo:
TheRealFawcett:lab8 javac
Student.java
Student.java:11: error: invalid method
declaration; return type required
public forName(String name) {
^
Edit: Eu não corrigi o erro na mensagem anterior, mas agora tenho um novo err
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$