hello.,i would like to create a method that accepts ...
hello,
i would like to create a method that accepts arrays as parameters and return an array as well, so,, please tell me whether the below stated java code is correct and if not, please guide me
Code Java:
public static String [] convertStrToInt (String [] , String [] )
{
.....
.....
.....
return ???
}
Re: hello.,i would like to create a method that accepts ...
Code java:
public static String [] convertStrToInt (String [] , String [] )
{
.....
.....
.....
return ???
}
A few things. First, the variables in your parameters need to be named:
Code java:
public static String [] convertStrToInt (String[] arr1 , String[] arr2 )
{
.....
.....
.....
return ???
}
Second, based on your declaration, you need to return a String[]:
Code java:
public static String [] convertStrToInt (String[] arr1 , String[] arr2 )
{
.....
.....
.....
//this is a basic return for a non-existent String[]
return new String[0];
}
Re: hello.,i would like to create a method that accepts ...
You need to declare the size of the string array, or you need to use an "in place" initializer
Code Java:
return new String[0]; // array of size 0
return new String[] {}; // array initialized to contain nothing