-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7d1399
commit f02f671
Showing
8 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |