I am an IT major and am required to take Java. I have a very basic understanding of C++ as I took a course over 5 years ago and do not remember much. Programming has always been tough for me to understand and I am having trouble completing the first homework for this course. I don't expect or really want to be given the answer to such a simple problem. I hope that this site will be able to help me for this semester and the future as I embark on a journey to be able to truthfully say I can write basic java programs. Of the program I am going to post, I get the gist of what everything in the code is however I do not know where or what I should type in the student.java file in order to return student information when the program is run. I guess what I am asking is, where do I need to create this method and what is REQUIRED to connect these two classes and display the data I want. Any tips would be greatly appreciated to a novice such as me.
This problem should be very simple but here is where I am stuck. I don't know how to create a method inside of student.java that returns
Using the classes below (app and student) create a solution for returning the complete student information using a method in the class student.
public class app
{
public static void main(String args[])
{
String initName = "John";
String lastName = "Smith";
int age = 22;
student st = new student(initName,lastName,age);
}
}
class student
{
String firstName;
String lastName;
int age;
student(String informedFirstName, String informedLastName, int informedAge)
{
firstName = informedFirstName;
lastName = informedLastName;
age = informedAge;
}
String getName()
{
return firstName +" "+lastName;
}
}
This problem should be very simple but here is where I am stuck. I don't know how to create a method inside of student.java that returns
Using the classes below (app and student) create a solution for returning the complete student information using a method in the class student.
public class app
{
public static void main(String args[])
{
String initName = "John";
String lastName = "Smith";
int age = 22;
student st = new student(initName,lastName,age);
}
}
class student
{
String firstName;
String lastName;
int age;
student(String informedFirstName, String informedLastName, int informedAge)
{
firstName = informedFirstName;
lastName = informedLastName;
age = informedAge;
}
String getName()
{
return firstName +" "+lastName;
}
}