This file contains hidden or 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 hidden or 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 hidden or 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); | |
} |
This file contains hidden or 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
// https://blog.udemy.com/java-data-types/?utm_source=adwords&utm_medium=udemyads&utm_campaign=DSA_Catchall_la.EN_cc.INDIA&utm_content=deal4584&utm_term=_._ag_82569850245_._ad_437477497173_._kw__._de_c_._dm__._pl__._ti_dsa-449490803887_._li_9061910_._pd__._&matchtype=b&gclid=CjwKCAjw0_T4BRBlEiwAwoEiAd5tg5iZ8c_k9pQxw5pX5HJoQKHjCc21ylREUKzHurajr3l7v2u5LhoCvKsQAvD_BwE | |
public static void main(String[] args) { | |
byte d = 127; // 2^7 = -128 -> 2^7-1 = 127 - 8 bits = 1 byte | |
short sh = 32767; // 16 bits = 2 bytes | |
int in = 2147483647; // 32 bits = 4 bytes | |
long lo = 9223372036854775807L; // 64 bits = 8 bytes | |
float fl = 23.44f; // 32 bits = 4 bytes | |
double db = 342.4; // 64 bits = 8 bytes | |
char ch = 'a'; // 16 bits - 2 byte | |
boolean bool = false; // 1 bit |
This file contains hidden or 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
@AndroidEntryPoint | |
class MainActivity : AppCompatActivity() { | |
// extn func from activity-ktx lib | |
val viewModel: MainViewModel by viewModels() | |
} |
This file contains hidden or 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
class MainViewModel | |
@ViewModelInject | |
constructor() : ViewModel() |
This file contains hidden or 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
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha01" | |
kapt "androidx.hilt:hilt-compiler:1.0.0-alpha01" |
This file contains hidden or 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
@AndroidEntryPoint | |
class MainActivity : AppCompatActivity() { | |
@Inject | |
lateinit var dummyClass: DummyClass | |
} |
This file contains hidden or 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
@Module | |
@InstallIn(ApplicationComponent::class) | |
class APIModule { | |
@Provides | |
fun giveAPIService(): API = Retrofit.Builder().build().create(API::class.java) | |
} |
This file contains hidden or 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
class DummyClass | |
@Inject | |
constructor() |