Question: what is the difference between java and apex?
Answer: The default access modifier in Apex is private, while in Java it is default. public in Java is not same as public in apex. public in Apex means the method or variable can be used by any Apex in this application or namespace. if you want to make something public like it is in Java, you need to use the global.