Skip to content

Commit

Permalink
sixth commit
Browse files Browse the repository at this point in the history
  • Loading branch information
surani-hub committed Sep 13, 2021
1 parent b7d1399 commit f02f671
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 0 deletions.
Binary file added Chap6_Assertions/AssertIdentifier.class
Binary file not shown.
27 changes: 27 additions & 0 deletions Chap6_Assertions/AssertIdentifier.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class AssertIdentifier{
public static void main(String[] args){
//int assert = 10;
//System.out.println(assert);

int x = 10;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
// assert(x>10):"Here x value should be greater than 10 but it's not";

// assert(x == 10):++x;

// assert(x>10):methodOne();

assert(x>10): methodTwo();

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
System.out.println(x);
}

/* public static int methodOne(){
return 999;
} */

public static void methodTwo(){
System.out.println("void return type method not allowed");
}
}
Binary file added Chap6_Assertions/AssertInsidePrivate.class
Binary file not shown.
10 changes: 10 additions & 0 deletions Chap6_Assertions/AssertInsidePrivate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AssertInsidePrivate{
private void stuff(int y){
assert(y<0);
}

public static void main(String[] args){
AssertInsidePrivate a = new AssertInsidePrivate();
a.stuff(10);
}
}
Binary file added Chap6_Assertions/AssertInsidePublic.class
Binary file not shown.
19 changes: 19 additions & 0 deletions Chap6_Assertions/AssertInsidePublic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class AssertInsidePublic{
int z = 5;

public void stuff(int x){
//assert(x<0):"print assert"; -- inappropriate usage

switch(x){
case 2: x = 3;
default: assert(false);
}
}

public static void main(String[] args){
AssertInsidePublic p = new AssertInsidePublic();
p.stuff(10);
}
}


Binary file added Chap6_Assertions/Two.class
Binary file not shown.
14 changes: 14 additions & 0 deletions Chap6_Assertions/Two.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Two{
public static void main(String[] args){

boolean assertOn = false;
assert(assertOn):assertOn = true;
if(assertOn){
System.out.println("assert is on ");
}

//assert(false):"executes only when assert is false";

//assert(args.length == 1);
}
}

0 comments on commit f02f671

Please sign in to comment.