Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

constructor with non essential vars

Tags:

java

android

I was wondering if it is possible and if so how, to create a constructor that takes three variables but will not through an error if the last two are not passed?

something like:

public void onCreate(Bundle savedInstanceState, String s1<non essential>) 
    {
like image 238
erik Avatar asked Jul 28 '26 06:07

erik


1 Answers

Create more contructors

public MyCreate(Bundle savedInstanceState) 
    {

public MyCreate(Bundle savedInstanceState, String s1) 
    {

public MyCreate(Bundle savedInstanceState, String s1, String s2) 
    {

try to read this article on constructor overloading.

like image 197
dash1e Avatar answered Jul 29 '26 21:07

dash1e



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!