Feature Overview
This feature infers variable types according to the context and make it final.
This feature infers variable types according to the context and make it final.
None
public class ValDemo {
public static void main() {
val t = 'String';
val size = t.length();
val str = t.toString();
val acc = new Account();
String [] slist = { 'a' };
val ref = slist;
}
}
public class ValDemo {
public static void main() {
final String t = 'String';
final Integer size = t.length();
final String str = t.toString();
final Account acc = new Account();
List slist = { 'a' };
final List ref = slist;
}
}
Refer to feature var
for more details.
Contribute on Github! Edit this section.