65 698
Assignments Done
99,2%
Successfully Done
In October 2018

Answer to Question #46966 in Java | JSP | JSF for neha reddy

Question #46966
Use Java code to write a function that converts an array of Strings to an array of integers.
Example:
arr = {“40”, ”50“, ”70”}
to arr = {40,50,70}.
Expert's answer

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
06.10.14, 13:50

Dear Rkosamia,
You're welcome. We are glad to be helpful. 
If you liked our service please press like-button beside answer field. Thank you!

Rkosamia
04.10.14, 02:18

Thank u so much...

Assignment Expert
02.10.14, 19:37

Dear Rkosamia,
you should create a project with a class where the main method

public static void main(String[] args) {

}

exists and place a call of the convertsArray function here, like in the following manner:
public class temp {
public static void main(String[] args) {
String [] arr = {"40", "50", "60"};
int[] iarr  = convertsArray(arr);
for (int i = 0; i < iarr.length; i ++) {
System.out.println(iarr[i]);
}
}
public static int[] convertsArray(String[] strArr) {
int[] iArray=new int[strArr.length]; 
for(int i=0; i<strArr.length; i++) { 
iArray[i] = Integer.parseInt(strArr[i]); 

return iArray; 
}
}

rkosamia
02.10.14, 03:37

your answer is correct i know that ., but in my netbeans IDE , it shows error about " there is no main method in class"

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions