Click here to Skip to main content
15,887,746 members
Home / Discussions / Java
   

Java

 
Questionhelp Pin
Member 1206925622-Mar-16 1:09
Member 1206925622-Mar-16 1:09 
AnswerRe: help Pin
Richard MacCutchan22-Mar-16 1:21
mveRichard MacCutchan22-Mar-16 1:21 
AnswerRe: help Pin
Patrice T22-Mar-16 1:47
mvePatrice T22-Mar-16 1:47 
SuggestionRe: help Pin
Member 1206925622-Mar-16 1:59
Member 1206925622-Mar-16 1:59 
GeneralRe: help Pin
Richard MacCutchan22-Mar-16 3:09
mveRichard MacCutchan22-Mar-16 3:09 
AnswerRe: help Pin
Richard Deeming22-Mar-16 3:01
mveRichard Deeming22-Mar-16 3:01 
QuestionHow to handle 404 page not found exception in Spring MVC with java configuration and no Web.xml Pin
glassShot10015-Mar-16 6:13
glassShot10015-Mar-16 6:13 
Questionhow do i fix this array out of bound index Pin
divinity0215-Mar-16 0:21
divinity0215-Mar-16 0:21 
hi everyone
i am new to this site. i am presently doing a practice java program to find reverse numbers, smallest and largest number out of the set of numbers enter and odd and even numbers

my problem is the smallest and largest. the odd and even numbers working okay, the reversed numbers working okay also

i am getting this arrayoutofbound index at line 41 and have been trying to figure out to fix it. can someone help. thanks in advance. here it the codes
another problems also it is repeating and i am not even getting the odd and even numbers to output.
C#
int arr[]= new int[10];

int i=0;
int largest=0,  smallest = 0,num;

for(i=0; i<=9; i++)
{
   System.out.println("please enter a number");
   arr[i] = userinput.nextInt();
}
for(i=9; i>=0; i--)
{
   System.out.println(arr[i]+"\t");
}

for(i=0; i<=arr.length; i++)
{
    if(i==0)
    {
        smallest = arr[i];
    }
    else if(arr[i] < smallest)
    {
         smallest = arr[i];
    }
    else if(arr[i]> largest)
    {
        largest = arr[i];
    }
     System.out.println("the smallest number is "+smallest);
     System.out.println("the largest number is "+ largest);

}

for(i=1; i<=9; i++)
{
    if(arr[i]%2==0)
    {
       System.out.println(arr[i]+" even number");
    }
    else if(arr[i]%2!=0)
    {
       System.out.println(arr[i]+" odd number");
    }
}

AnswerRe: how do i fix this array out of bound index Pin
Richard MacCutchan15-Mar-16 2:40
mveRichard MacCutchan15-Mar-16 2:40 
GeneralRe: how do i fix this array out of bound index Pin
divinity0215-Mar-16 9:28
divinity0215-Mar-16 9:28 
GeneralRe: how do i fix this array out of bound index Pin
Richard MacCutchan15-Mar-16 10:37
mveRichard MacCutchan15-Mar-16 10:37 
GeneralRe: how do i fix this array out of bound index Pin
divinity0215-Mar-16 21:46
divinity0215-Mar-16 21:46 
AnswerRe: how do i fix this array out of bound index Pin
Patrice T16-Mar-16 16:26
mvePatrice T16-Mar-16 16:26 
GeneralRe: how do i fix this array out of bound index Pin
divinity0217-Mar-16 9:51
divinity0217-Mar-16 9:51 
QuestionNew To Java Pin
aahamdan13-Mar-16 4:15
aahamdan13-Mar-16 4:15 
AnswerRe: New To Java Pin
Richard MacCutchan13-Mar-16 7:13
mveRichard MacCutchan13-Mar-16 7:13 
Questionjava Pin
Member 1238766612-Mar-16 8:14
Member 1238766612-Mar-16 8:14 
AnswerRe: java Pin
Richard MacCutchan13-Mar-16 0:10
mveRichard MacCutchan13-Mar-16 0:10 
QuestionUsing recursion Pin
Member 1238223510-Mar-16 18:42
Member 1238223510-Mar-16 18:42 
AnswerRe: Using recursion Pin
Richard MacCutchan10-Mar-16 21:25
mveRichard MacCutchan10-Mar-16 21:25 
GeneralRe: Using recursion Pin
Member 1238223510-Mar-16 22:15
Member 1238223510-Mar-16 22:15 
GeneralRe: Using recursion Pin
Richard MacCutchan11-Mar-16 2:36
mveRichard MacCutchan11-Mar-16 2:36 
AnswerRe: Using recursion Pin
Patrice T16-Mar-16 15:26
mvePatrice T16-Mar-16 15:26 
QuestionDoubt regarding Java coding Pin
Sweacha Nlakshmi10-Mar-16 18:16
Sweacha Nlakshmi10-Mar-16 18:16 
GeneralRe: Doubt regarding Java coding Pin
Richard MacCutchan10-Mar-16 21:24
mveRichard MacCutchan10-Mar-16 21:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.