+ 2
Add() method not exist in ArrayList class ! ?
I tried to add new elements to an ArrayList, but there is no add method shown in eclipse...
3 ответов
+ 2
The problem was with ArrayList declaration!
If following regular way of declaration didn't work
>> ArrayList<String> colors = new ArrayList<String>();
try this kind of definition:
>> java.util.ArrayList<String> colors = new java.util.ArrayList<>();
It works for me.
0
the add method does exist. Just make sure you write it in small letters and that you use it properly. Eg.
ArrayList <String> myArr = new ArrayList<String>();
//using the add method
myArr.add("anyString");
0
Java naming conventions:
class name - starts with capital letter
methods, objects and variables - lower letter, camel case
package name - all lower letter case
constants - all capital letter separated by underscores.