Hi guys!
This requirement is not verified:
The program must record the lengths of the strings in the number array, and then display them on the screen.
Why?
Thanks a lot!
package com.codegym.task.task07.task0703;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
/*
Lonely arrays interact
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
String[] array1 = new String[10];
int[] array2 = new int[10];
int nameLength = 0;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < array1.length; i++)
{
array1[i] = reader.readLine();
nameLength = array1[i].length();
}
for (int j = 0; j < array2.length; j++) {
array2[j] = nameLength;
}
System.out.print(Arrays.toString(array2));
}
}
package com.codegym.task.task07.task0703;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
/*
Lonely arrays interact
*/
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
String[] array1 = new String[10];
int[] array2 = new int[10];
int nameLength = 0;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < array1.length; i++)
{
array1[i] = reader.readLine();
nameLength = array1[i].length();
}
for (int j = 0; j < array2.length; j++) {
array2[j] = nameLength;
}
System.out.print(Arrays.toString(array2));
}
}