小编Sha*_*ikh的帖子

当年龄不在范围之间时,抛出用户定义的异常

我创建了一个class Studentwith属性:rno, age, name, course我已经定义了一个参数化的构造函数.我想age在15到21之间抛出一个异常.我已经初始化age为27但是它没有进入if条件.你知道为什么会这样吗?

   class Age extends Exception
   {
   Age(String str)
   {
    super(str);
   }
  }

  public class Student
  {
   int rno,age;
   String name,course;

   Student(int r,int a,String n,String c) 
   { 
    rno=r;
    age=a;
    name=n;
    course=c;
   }

   public void display()
   { 
    try
      {
       if(age<=15 && age>=21)
          throw new Age("Not accepted");
       else 
        System.out.println("Name:"+name);
        System.out.println("Rno:"+rno);
        System.out.println("Age:"+age);
        System.out.println("Course:"+course);
        System.out.println("...........");
      }

   catch(Age a)
    {
       System.out.println(""+a);
    }
   }

   public static void main(String args[])
   {
    Student s1=new Student(1,26,"ABC","Java");
    Student s2=new …
Run Code Online (Sandbox Code Playgroud)

java constructor if-statement exception-handling try-catch

0
推荐指数
1
解决办法
734
查看次数

显示在10月月的周日雇用的员工姓名

我的练习是为了显示10月份在星期天雇用的员工姓名

select ename,hiredate    from emp   where
to_char(hiredate,'MON')='OCTOBER' AND to_char(hiredate,'DAY')='SUNDAY'
Run Code Online (Sandbox Code Playgroud)


显示上一季度雇用的所有员工.

在oracle中我们不能使用qq,那么如何为此编写查询?

sql oracle date-formatting

-1
推荐指数
1
解决办法
2万
查看次数