function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SDFC FirstLevelerSDFC FirstLeveler 

I am getting unexpected token error please see the below code:

public class MyFirstProgram {
    public void sfClass() {
        for(Integer i=1; i<=5; i++){
            for(Integer j=1; j<=5; j++){
                if(j<=i){
                    System.debug('*');
                    else{
                        system.debug(' ');
                    }
                }
            }
        }
    }
}
MyFirstProgram Program =new MyFirstProgram();
Program.sfClass(); 
Malni Chandrasekaran 2Malni Chandrasekaran 2
Abishek,
Please try,

public class MyFirstProgram {
    public void sfClass() {
        for(Integer i=1; i<=5; i++){
            for(Integer j=1; j<=5; j++){
                if(j<=i){
                    System.debug('*');   }   // You have misplaced this RBrace
                    else{
                        system.debug(' ');
                    }
                
            }
        }
    }
}
 
Please mark it as solved if you find it helpful.