SAP-Abap Learning Record (2)


package com.soar.exception;

public class Demo6_Exception {
     * A: Throws to handle abnormalities 
     * When defining the function method, the problems that appear need to be exposed for the calling person to deal with it. 
     * Then the method is identified by Throws. 
     * B: Case demonstration 
         * For example, the abnormal and abnormal throwing during the compilation of the compilation 
         * The abnormality of compilation must be processed by it 
         * The abnormalities at the run can be processed or not handled 
 *************************************************** ************ 
     * A: Throw Overview 
     * Some cases appear inside the function method. The program cannot continue to run. When jumping is needed, use Throw to throw an abnormal object. 
     * B: Case demonstration 
     * Demonstrate the abnormal object and the abnormal object during the compilation of the compilation 
     * C: Throws and Throw 
     * A: Throws 
         * Use behind the method to declare, follow the abnormal category name 
         * You can separate it with multiple abnormal categories and use comma 
         * It means throwing an exception, and the caller of this method is handled 
     * B: Throw 
         * Used in the method body, follow the abnormal object name 
         * You can only throw out an abnormal object name 
         * Indicates throwing abnormality, and the statement in the method is processed 
    public static void main(String[] args) throws Exception {
        Person p = new Person();

class Person{
    private String name;
    private int age;
    public Person() {

    public Person(String name, int age) {
        super(); = name;
        this.age = age;
    public String getName() {
        return name;
    public void setName(String name) { = name;
    public int getAge() {
        return age;
    public void setAge(int age) throws Exception,RuntimeException {
        if(age > 0 && age <=150){
        this.age = age;
            // Exception E = New Exception ("Age illegal");
            //throw e;
            throw new Exception("Age illegal");    // Writing above


Related Posts

UNI-APP network request packaging and login authorization

Oracle’s large data volume migration, and inlet import samples (fetch … bulk collect) and Forall combined

jQuery’s scrolllect and scrollTop method to slide method analysis

Sorting Algorithm-Base Sorting-Detailed Explanation and Code Analysis

SAP-Abap Learning Record (2)

Random Posts

MyBatis-Plus Insert Times Error Order

Competition Practice Issue 15: Electronic Society September 2021 Youth Software Programming (graphic) level test papers (level 3) …

Custom dialog box, progress bar, drop -down refresh, etc.

nlp | Natural language processing -grammar analysis

Unity3D —— Model Click events