print numbers using Tostring in java

Asked

Viewed 85 times

-2

Project scribble plus it didn’t print the numbers inside the []...

package tostring2;

import java.util.Arrays;


public class ToString2 {

    public static String ToString2(int [] a) {

       int idades [] = {12,20,30,40};
       int i;

       for (i = 0; i < 4 ; i++){
          System.out.println(idades[i]);
       }
       for (i=0; i < idades.length;i++){
          System.out.println("idades "+Arrays.toString(idades));
       }
}
  • I was editing your question and I realized I was missing a key lock }. I don’t know if your source is like this, but if it is, it could be the cause of the mistake

1 answer

0


You created a method but you didn’t call it.

Create a main method and call it inside it. Example:

public static void main (String[] args)
{
    ToString2();
}

See it working on Ideone: http://ideone.com/M834OQ

  • It worked by creating Main Method... Thanks for the help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.