I try to understand the difference between example 1 and example 2 below, and why it matters, what to call.
I think, I understand that, Example 1 I call the class Idea and Example 2 I call the object of Idea-class.
But why does it matter, and when to prefer the example 1 over example 2, and the other way around.. ?
Example 1:
public class Solution {
public static void main(String[] args) {
printIdea(new Idea());
}
public static void printIdea(Idea idea) {
System.out.println(Idea.getDescription());
}
public static class Idea {
public static String description = "Anita";
public static String getDescription() {
return description;
}
}
}
vs.
Example 2:
public class Solution {
public static void main(String[] args) {
printIdea(new Idea());
}
public static void printIdea(Idea idea) {
System.out.println(idea.getDescription());
}
public static class Idea {
public static String description = "Anita";
public String getDescription() {
return description;
}
}
}