how do you stop search in a loop once you meet the condition : how do you stop the for each loop from proceeding when the condition is false? because I can only let x = newX when all the object in the collection is true to the condition. thank you for help. break won't help, I tried.

        for (char  h : collection){
             if ( condition == false )
            {
               
            }
            else{
                x = newX;
            }
        }