DEV Community

Sasireka
Sasireka

Posted on

Debugging in Java

  • Debugging is the process of finding and fixing errors (bugs) in a program so that it works correctly.

  • Example 1: Syntax Error (Missing Semicolon)

public class Home {
    public static void main(String[] args) {
        System.out.println("Hello, World!")
    }
}
Enter fullscreen mode Exit fullscreen mode

  • Example 2: Case Sensitivity Error
public class Home {
    public static void main(String[] args) {
        system.out.println("Hello, World!");
    }
}
Enter fullscreen mode Exit fullscreen mode

  • Example 3: Missing Curly Braces
public class Home 
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
Enter fullscreen mode Exit fullscreen mode

  • Example 4: Unclosed String Literal
public class Home {
    public static void main(String[] args) {
        System.out.println("Hello, World!);
    }
} 
Enter fullscreen mode Exit fullscreen mode

  • Example 5: Missing double quotes
public class Home {
    public static void main(String[] args) {
        System.out.println(Hello, World!);
    }
}
Enter fullscreen mode Exit fullscreen mode

  • Example 6: Main Method Signature Error(Runtime Error)
public class Home {
    public static void main(String args) {
        System.out.println("Hello World!");
    }
}
Enter fullscreen mode Exit fullscreen mode

  • Example 7: Cannot Find Symbol Error(Compilation Error)
public class Home {
    public static void main(string[] args) {
        System.out.println("Hello World!");
    }
}
Enter fullscreen mode Exit fullscreen mode

  • Example 8: Incorrect keyword case(Syntax Error)
Public Class Home {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
Enter fullscreen mode Exit fullscreen mode

  • Correct Code
public class Home {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)