//
Integer i = new Integer(100);
Long l = new Long(100);
String s = new String("A");
//
Integer i = Integer.valueOf(100);
Long l = 100L;// Long.valueOf(100L);
String s = "A";
//
String[] fields = new String[] {"a","b","c","d","e","f","g"};
String s = "";
for (int i = 0; i < fields.length; i++) {
s = s + fields[i];
}
return s;
//
String[] fields = new String[] {"a","b","c","d","e","f","g"};
StringBuilder s = new StringBuilder();
for (int i = 0; i < fields.length; i++) {
s.append(fields[i]);
}
return s.toString();
//
List a = new ArrayList();
//
List<String> a = new ArrayList<String>();
//
interface A {
public static final String A = "a";
}
//
final class A {
public static final String A = "a";
}
Collections.emptyList();
Collections.emptyMap();
Collections.emptySet();
Set<Document> docs = getDocuments(plan);
for (Document doc : docs) {
sendMessage(doc.getOwner());
}
public static Set<Document> getDocuments(Plan plan) {
//some logic
if (isDoSomethingOk() && hasAccessToDocuments(user)) {
return plan.getDocuments();
}
return Collections.emptySet();
}
//
int a = 12;
String s = a + "";
//
int a = 12;
String s = String.valueOf(a);
Source: https://habr.com/ru/post/132241/