+ 2

Why this errorException in thread "main" java.util.NoSuchElementException

https://code.sololearn.com/c8E2TUjJZxL1 Thanks

30th Jul 2018, 1:18 PM
wally22
9 Respuestas
+ 5
Ibney Ali Thanks for the cooperation. Please don't forget to remove it here too.
30th Jul 2018, 9:10 PM
Koketso Dithipe
Koketso Dithipe - avatar
+ 4
You must enter all the required numbers line by line before running the application For your example: 5.5 10.8 (two doubles)
30th Jul 2018, 1:56 PM
Mishin870
Mishin870 - avatar
+ 2
class Program { public static void main(String[] args) { String a1= new String("Literal"); String a2 = "Literal"; System.out.println(a1.hashCode()); System.out.println(a2.hashCode()); } } Why same of both hashCode is same where both object creation is diffrent in string?
30th Jul 2018, 7:08 PM
Ibney Ali
Ibney Ali - avatar
+ 1
all inputs give first.. before running...
30th Jul 2018, 4:54 PM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
+ 1
thanks guys
30th Jul 2018, 7:28 PM
wally22
+ 1
Ibney Ali The statement String str = new String("Literal"); creates a string object which gets stored on the heap like any other object. The string literal "test" that is passed as an argument is stored in the string constant pool. String#intern() checks if a string constant is already available in the string pool. If there is one already it returns it, else it creates a new one and stores it in the pool.
31st Jul 2018, 3:50 AM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
+ 1
Pawan sir I think this is not correct answer or may be i did not understand.
31st Jul 2018, 3:55 AM
Ibney Ali
Ibney Ali - avatar
+ 1
Ibney Ali When you use String str = new String("test"); it will creates two objects and one reference variable. In such case, JVM will create a new string object in normal(non pool) heap memory and the literal "test" will be placed in the string constant pool. Firstly JVM will not find any string object with the value "Welcome" in string constant pool, so it will create a new object. After that it will find the string with the value "Welcome" in the pool, it will not create new object but will return the reference to the same instance.
31st Jul 2018, 4:02 AM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
0
you are getting the error because you are taking input two times for the variable "lu" so instead create a new variable say "li" and then replace it with the second "lu" input statement and then run
30th Jul 2018, 2:02 PM
Suhail Pappu
Suhail Pappu - avatar