ControlC
· Pastebin
Login
Register
ControlC
/
Create paste
Paste content
Up to 100 KB of text. BBCode formatting is supported.
Title
- optional
Content
B
I
U
S
</>
Colors ↓
Sizes ↓
Size 1
Size 2
Size 3
Size 4
Size 5
Size 6
Size 7
public class SampleClass{\r\n \r\n //invalid: can't use var\r\n //keyword as type of\r\n //instance variable\r\n //var myVar = false;\r\n \r\n void meth1(){\r\n //var can be used in this\r\n //block\r\n var str = \"String\";\r\n \r\n //var can be used in for loop\r\n //parentheses\r\n for(var i = 0; i < 3;i++)\r\n System.out.println(str);\r\n }\r\n \r\n //invalid: var can't be used as\r\n //type of method and constructor\r\n //parameter\r\n //void meth2(var param){}\r\n \r\n public static void main(String[]args){\r\n //var can be used here 'cause main()\r\n //is a method like meth1()\r\n var chararacter = 'c';\r\n \r\n //var can't be used as type of an array\r\n //var[] myStr = new String[]{\"A\",\"B\"};\r\n \r\n String[] str = new String[]{\"A\",\"B\"};\r\n \r\n //var can be used in for-each loop\r\n //parentheses\r\n for(var s : str)\r\n System.out.println(s);\r\n }\r\n}
Password
Anyone with the link will still need this password to view.
Expires
1 hour
3 hours
6 hours
12 hours
24 hours
48 hours
72 hours
Sign in to enable "Never expires".
Create paste
Please verify you are human
Cancel