Beneath is a pair of classes that I came across in a youtube tutorial. I have come to understand it's functionality almost in its entirety, and I would like to use something similar in a project.
However, I would generally assume that issues would arise if I had multiple instances named Mark..whether it is in the same class file or separate, still in package myClass.
I would like to know if anyone has any ideas on the matter for getting around this, I am fairly new to Java so I would be happy with even a general direction. I have become increasingly more familiar with Java naming conventions over the past couple days but the few articles and videos that I have come across thus far have not yet come to help me understand or workaround this.
In my real world application I am using an ID associated with Mark to name the classes...but so far one would need to do extra work to figure out who's id they are looking at....not a big issue, but an inconvenience. When invoked I could use print or return statements for getName, but this, I think is beside the point...my question is with giving multiple classes/instances similar tags.
Should I stick with the very unique alphanumeric ID as not only the class name but the instance name as well or can i have a 2nd class under a different class name, but with its own unique values in instance Mark?
package myClass
public class ThisClass{
public static void main (String[] args){
Student Mark = new Student();
Mark.setName("Mark");
}
}
DIFFERENT CLASS IN PACKAGE myClass;
public class Student{
String name;
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
}