我是Java的Begginer,在这里有如此深刻的见解。 int给出了一个nullexception,我不认为在这里使用Integer是一个很好的做法,因为稍后我将不得不使用int Pages但因为它将是Integer我将不得不继续使用(Integer.valueOf(17)== 17);只是为了使Integer成为一个int,因为Integer无法与int进行比较。
public class TestBook {
public static void main(String[] args) {
// = = = =
// Instantiating an empty Book object; for example: Book1, for testing
Book Book1 = new Book("Renewable Energy","John Smith",209);
Book Book2 = new Book("Harry Potter PS ","JK Rowling",null);
Book Book3 = new Book("Harry Potter PA ","JK Rowling",-1);
System.out.println("Test for object Book1");
System.out.println("=====================");
System.out.println(Book1.printBook());
System.out.println(Book2.printBook());
System.out.println(Book3.printBook());
}
}
// Mainclass
Declare @MyList table
(
PhotoId INT
)
DECLARE @Id INT
INSERT INTO @MyList
Select PhotoId From tblContactAndtblContactPhoto Where ContactId=@Id;
DELETE From tblContactAndtblContactPhoto Where ContactId=@Id;
Delete tblContactPhoto Where Id IN(SELECT PhotoId FROM @MyList)