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
dependencies { | |
... | |
// For instrumented tests. | |
androidTestImplementation 'com.google.dagger:hilt-android-testing:2.28-alpha' | |
kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.28-alpha' | |
androidTestImplementation "io.mockk:mockk-android:1.9.3" | |
androidTestImplementation "com.squareup.okhttp3:mockwebserver:4.6.0" | |
... | |
} |
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
public static void main(String[] args) { | |
HashMap<Character, Character> map = new HashMap<>(); | |
map.put('(', ')'); | |
map.put('{', '}'); | |
map.put('[', ']'); | |
String ipString = "{[}]"; | |
System.out.println(isBalancedParenthesis(map, ipString)); | |
} |
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
public static void main(String[] args) { | |
int i = 10; | |
Integer ii = new Integer(i); // boxing - putting primitive type in wrapper classes | |
Integer iii = i; // auto-boxing - putting primitive type in wrapper classes | |
int j = ii.intValue(); // unboxing - getting primitive type from wrapper classes | |
int jj = iii; // auto-unboxing - gettingg primitive types from wrapper classes | |
System.out.println(i); | |
System.out.println(ii); |
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
fun main() { | |
val bluePen = Pen(inkColor = "Blue") | |
bluePen.showInkColor() | |
val blackPen = Pen(inkColor = "Black") | |
blackPen.showInkColor() | |
val blueBlackPen = bluePen + blackPen | |
blueBlackPen.showInkColor() | |
} |
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
fun main() { | |
val emp1 = Employee(name = "audhil", id = 33) | |
val emp2 = Employee(name = "audhil", id = 33) | |
if (emp1 == emp2) { | |
println("equal") | |
} else | |
println("not equal") | |
println(emp1.hashCode()) |
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
// based on http://www.theappguruz.com/blog/android-time-zone-demo | |
class DummyActivity : Activity() { | |
private var spinnerAvailableID: Spinner? = null | |
private var current: Calendar? = null | |
private var textTimeZone: TextView? = null | |
private var txtCurrentTime: TextView? = null | |
private var txtTimeZoneTime: TextView? = null | |
private var miliSeconds: Long = 0 | |
private var idAdapter: ArrayAdapter<String>? = null |
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
// based on http://www.theappguruz.com/blog/android-time-zone-demo | |
class DummyActivity : Activity() { | |
private var spinnerAvailableID: Spinner? = null | |
private var current: Calendar? = null | |
private var textTimeZone: TextView? = null | |
private var txtCurrentTime: TextView? = null | |
private var txtTimeZoneTime: TextView? = null | |
private var miliSeconds: Long = 0 | |
private var idAdapter: ArrayAdapter<String>? = null |
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
public class WaitNotifyDemo { | |
public static void main(String[] args) { | |
Q q = new Q(); | |
new Producer(q); | |
new Consumer(q); | |
} | |
static class Q { | |
private int num; |
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
public class DeepCloneDemo { | |
public static void main(String[] args) throws CloneNotSupportedException { | |
Employee employee = new Employee("audhil", 31, new Address(11, 782382)); | |
System.out.println("employee:" + employee); | |
Employee employee2 = (Employee) employee.clone(); | |
System.out.println("employee2:" + employee2); | |
employee2.setAddress(new Address(33, 4342)); | |
System.out.println("employee:" + employee); | |
System.out.println("employee2:" + employee2); |
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
public class ShallowCloneDemo { | |
public static void main(String[] args) throws CloneNotSupportedException { | |
Employee employee = new Employee("audhil", 31); | |
System.out.println(employee); | |
Employee employee2 = (Employee) employee.clone(); | |
System.out.println(employee2); | |
employee2.setAge(33); | |
employee2.setName("yup"); | |
System.out.println(employee2); | |
} |