Java Stringarrays


#1

public class jackmaaaa
{
public static void main (String args[])
{
String arr[]={“TRISECT”,“IS”,“FUN”};
int len=arr.length;
int i=0,count=0;
for(i=0;i<len;i++)
{
String str=arr[i];
int x=str.length();
if(x>2){
count=count+1;
}
}
int size=count;
String arr2[]=new String[size];
int len2=arr2.length;
int index=0;
for(i=0;i<len;i++){
String str=arr[i];
int x=str.length();
if(x>2)
{
arr2[index]=arr[i];
index++;
System.out.println(arr2[i]);
}

}
{
}
}
}

//Getting an error ,i just want to print the strings whose length is greater than 3

output = Trisect fun

help me


#2

What error? Error messages contain information about what went wrong, you should be looking at them when they show up, and if you have a question about them then you should include them in the question because they explain the situation, or at least a significant part.
Please put ``` betfore and after your code to make sure others can copy it accurately, otherwise they may be looking at different code
What information are you missing to fix the problem? What’s your understanding of what it says?


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.