+ 2

What means violate the naming convention for Java class names?

Hi! My assignment was not accepted because "violate the naming convention for Java class names" What does it mean and what should I change? Thanks!

12th Feb 2018, 2:09 AM
DIY Mods
DIY Mods - avatar
5 Réponses
+ 7
Java, like many other languages, has conventions when writing code. They mainly refer to what rules we should follow to name our elements, although they also include the use of some elements of the language. Following that the names of the classes in Java must have the first letter capitalized, and if the name is composed the subsequent words also. In the same way it is prioritized that the name is descriptive in relation to what they do. Example: class MyFirstClass; class ProcessAudio; Here you have more information: http://www.oracle.com/technetwork/java/codeconventions-135099.html
12th Feb 2018, 2:19 AM
Mickel
Mickel - avatar
+ 5
@DIY Mods. To answer your last question: You can call the non-static method from static one by creating an object of the class that owns it so you can use the method.
12th Feb 2018, 3:32 AM
Fabio
+ 5
Ok... Attribute and field are the same, and a field is also called variable instance as long as that field be an non-static variable. So that variable name is an attribute, field, data member, and instance variable.
12th Feb 2018, 3:54 PM
Fabio
+ 4
You need show us your code. Anyway, this seems you're trying to assign something in a wrong way. Look, all fields/variables/methods/classes should starts with letter (upper or lower case) or underline (_). Do you tried name something without following this rule? (Starting names with number or special character i.e.)
12th Feb 2018, 2:20 AM
Lucas Sousa
Lucas Sousa - avatar
+ 1
Thank you, Fabio! If you don't mind, one more: Name in this field called: attribute, data member, instance variable but not atribute or field, correct? public class Person { private String name; // attribute
12th Feb 2018, 3:55 AM
DIY Mods
DIY Mods - avatar