+ 4

Why my this program show exception????

https://code.sololearn.com/c5qnEydZh2Dp/?ref=app n also if i want to print the smallest word then what can i do???? Arun Tomar Gaurav Agrawal Fata1 Err0r Amir Itai Meshulam

7th Jun 2018, 3:36 PM
Harsh Agrawal
Harsh Agrawal - avatar
9 odpowiedzi
+ 2
This is your code https://code.sololearn.com/c0KyIiJYLZmW/?ref=app longest and shortest words and their lengths
8th Jun 2018, 9:45 PM
[A^dr3w]
[A^dr3w] - avatar
+ 3
your error was slight, but it earned you an error https://code.sololearn.com/cXXpYnZzKuxw/?ref=app
7th Jun 2018, 3:41 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 3
Array Index Bound Exception it come when you try to traverse the array greater the size of the define length.... for eq. int a[]=new int[5]; As you know.. the array base index start with 0 so 0,1,2,3,4 now count above number i.e 5... so you must run the loop for(int i=0;i<a.length; i++) as you know a.length have a value 5.. so loop run 0 to 4 i.e 5.. .. now in your program. you run the loop for(int i=0;i<=a.length; i++) that mean you loop run 0 to 5 0,1,2,3,4,5 now count the number i.s 6 and you define the size of array of 5.. i.e exception show...... your program have some logical error too.. Harsh Agrawal .. use comments for better readability of your program......
8th Jun 2018, 7:10 AM
Arun Tomar
Arun Tomar - avatar
+ 3
Harsh Agrawal .. sorry for the late reply. i want to asked something.. you want to find the largest word from the given input
8th Jun 2018, 5:24 PM
Arun Tomar
Arun Tomar - avatar
+ 3
do you know how to use javadoc Harsh Agrawal .. back to your question.. used split() (split from space) function to split the paragraph into the words.. of array.. now used function toCharArray() functions to triversed the split words and used count array.. to count the no of word... in each words... now used if else conditions.. to find largest and smallest one... one note.. there are so many way to do that bro.. what i come up an idea at short time.. I tell you this... pls learn how to used javadoc.. it better.......
8th Jun 2018, 6:24 PM
Arun Tomar
Arun Tomar - avatar
+ 2
🇳🇬Brains but it not give the right ans as d largest word is well n what do u correct in this program i cant get my problem where i did wrong???? n if i want to print d smallest word den what can i do?????
7th Jun 2018, 3:44 PM
Harsh Agrawal
Harsh Agrawal - avatar
+ 2
Arun Tomar i used comments on my code so plzzz check out my code again n solve my problem plzzzzz
8th Jun 2018, 12:45 PM
Harsh Agrawal
Harsh Agrawal - avatar
+ 2
thnxxxxxx Arun Tomar n [A^dr3w] ...
9th Jun 2018, 2:41 PM
Harsh Agrawal
Harsh Agrawal - avatar
0
Arun Tomar ya i want to print d largest word but der is not coming n also if i want to print smallest word then what can i do????
8th Jun 2018, 5:58 PM
Harsh Agrawal
Harsh Agrawal - avatar