+ 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
9 odpowiedzi
+ 2
This is your code
https://code.sololearn.com/c0KyIiJYLZmW/?ref=app
longest and shortest words and their lengths
+ 3
your error was slight,
but it earned you an error
https://code.sololearn.com/cXXpYnZzKuxw/?ref=app
+ 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......
+ 3
Harsh Agrawal ..
sorry for the late reply.
i want to asked something..
you want to find the largest word from the given input
+ 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.......
+ 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?????
+ 2
Arun Tomar i used comments on my code so plzzz check out my code again n solve my problem
plzzzzz
+ 2
thnxxxxxx Arun Tomar n [A^dr3w]
...
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????