How do I print the strings from array which is starting from A and his length is greater than 4? | Core Java Forum
V
Vikrant Posted on 24/07/2021

Hi Yogesh,

 

Please help me with below program?


Y
Yogesh Chawla Replied on 24/07/2021

Check this:

public class FilterWordsFromArray {

	public static void main(String[] args) {

		String[] input = {"ABCDE","BCDEFR","ABFRE","SWDER","HGD", "ABC"};

		for(int i=0; i < input.length; i++) {
			if (input[i].startsWith("A") && input[i].length() > 4) {
				System.out.print(input[i] + " ");
			}
		}
	}
}

Change the input array according to how you need.


V
Vikrant Replied on 24/07/2021

Thanks Yogesh