+ 1

Please help me! I start something by didn't work

How to selec the only 4 character Strings within the LinkedList. import java.util.LinkedList; public class MyClass { public static void main(String[ ] args) { LinkedList<String> c = new LinkedList<String>(); c.add("Red"); c.add("Blue"); c.add("Green"); c.add("Orange"); c.add("Cocojambo") for(int i=0, i<c.length , i++) { if(c.get(i).length()>6){ System.out.println(c.add(i)); } } }

8th Jun 2021, 9:43 PM
Remus Tanasa
2 Answers
+ 1
Thanks a lot for the correction !!!
9th Jun 2021, 7:59 AM
Remus Tanasa
0
//Is this a duplicate or another question, but I find need more corrections... Read comments.. /*Please help me! I start something by didn't work How to selec the only 4 character Strings within the LinkedList. */ import java.util.LinkedList; public class MyClass { public static void main(String[ ] args) { LinkedList<String> c = new LinkedList<String>(); c.add("Red"); c.add("Blue"); c.add("Green"); c.add("Orange"); c.add("Cocojambo") ;//you forgot ; for(int i=0; i<c.size() ; i++) //use c.size() and add semicolon ,not camma in loop blocks { if(c.get(i).length()==4){ //for only 4chars length, for greater or equal 4 use >=4 System.out.println(c.get(i)); //use c.get(i) to print, but you are using c.add(i) } } } }//add this also
9th Jun 2021, 7:28 AM
Jayakrishna 🇼🇳