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
// 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 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 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 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 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 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 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() |
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
@HiltAndroidApp | |
class NewsApplication : Application() |
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
// project level build.gradle | |
classpath 'com.google.dagger:hilt-android-gradle-plugin:{latest_version}' |
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
// app/build.gradle | |
implementation "com.google.dagger:hilt-android:{latest_version}" | |
kapt "com.google.dagger:hilt-android-compiler:{latest_version}" |