Skip to main content

Error with Array

2 replies [Last post]
leandro_1981
Offline
Joined: 2011-11-05
Points: 0

Dear Friends;

I started to study java a few weeks ago and I am not getting to use Array with int.

For exemplo:

int [] number = new int [5];

number[0] = JOptionPane.shomInputDialog (null, "Choose a number");

(....)

When I run Javac return that need int and there`s string.

Someone help me please!

And, sorry if my english is so bad!

Thanks!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
amitsoni1234
Offline
Joined: 2011-10-07
Points: 0

Hi,

This is the sample program of array:

package com.inter;

public class ArrayTest
{
static int arr[] = new int[10];

public static void main(String[] args)
{

// Assigning values to array..
for(int i=0;i<10;i++)
{
arr[i] = i;
}
// Displaying values of array
for (int k=0;k<arr.length;k++)
{
System.out.println("Value of arr..." + arr[k]);
}

}

}

Pls let me know if any other help from my side....

Amit

leandro_1981
Offline
Joined: 2011-11-05
Points: 0

Thanks!! Your explanation is enough!