Skip to content

Instantly share code, notes, and snippets.

View LocalVariableTypeInferenceExample4WithError.java
package ir.soheil_gh;
public class LocalVariableTypeInferenceExample4WithError {
public static void main(String[] args) {
var test = null;
}
}
View LocalVariableTypeInferenceExample3WithError.java
package ir.soheil_gh;
public class LocalVariableTypeInferenceExample3WithError {
public static void main(String[] args) {
var test = {1,2,3};
}
}
View LocalVariableTypeInferenceExample2WithError.java
package ir.soheil_gh;
public class LocalVariableTypeInferenceExample2WithError {
public var test = "12";
public static void main(String[] args) {
}
}
View LocalVariableTypeInferenceExample1WithError.java
package ir.soheil_gh;
public class LocalVariableTypeInferenceExample1WithError {
public static void main(String[] args) {
var test;
}
}
View LocalVariableTypeInferenceExample.java
package ir.soheil_gh;
import java.util.HashMap;
public class LocalVariableTypeInferenceExample {
public static void main(String[] args) {
var test = "soheil";
System.out.println(test.getClass().getCanonicalName());
var test2 = 2*2; // test2 is int
@soheil-ghahremani
soheil-ghahremani / ParameterPassingTest.java
Last active Sep 10, 2019
Java uses only call by value while passing variables
View ParameterPassingTest.java
package ir.soheil_gh;
public class ParameterPassingTest {
public static void main(String[] args) {
int a = 10;
System.out.println("value of a before calling change method: " + a);
change(a);
System.out.println("value of a after calling change method: " + a);
@soheil-ghahremani
soheil-ghahremani / StringTest.java
Created Aug 23, 2019
difference between String and StringBuilder and StringBuffer
View StringTest.java
package ir.soheil_gh;
public class StringTest {
public static void main(String[] args) {
long t1 = System.currentTimeMillis();
String initialString = "";
for(int i=0; i<50000; i++ ){
initialString += i;
}