0
I’m new to Java
and I’d like to understand how it works.
Like, how I use classe
inside the other (and what’s it called)?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
For example: it is sending the Bundle
in the method but he is not a String
neither a int
or similar. How exactly this works?
And another. When we create a variable String
, for example:
String a = "aa";
Why don’t we need to use the operator new
and what happens if we stop using it on some object?
Your second question is answered here: http://answall.com/q/19098/3117 . Always try to keep only one question per topic, if the link I gave you answer your question you can remove it by editing your question.
– Math
Your first question is confused. Do you understand how methods work? Well, the parameter in this case is an object of the Bundle type, rather than being a
int
or a String. What you want to know how it works in this?– Math
Yes.. That’s what’s leaving me in doubt.. Why not an int or string but a Bundle? Like it’s not a primitive value. How it works?
– mrlucasrib
So what you want to understand then is how do objects work? Have you ever created a class? Initialized it? Called it methods? Objects are like primitive types, only more complex, rs.. They’re like a struct enhancement of C. Ah, and String in Java is a class, it’s not primitive like
int
or thedouble
.– Math
So... But I don’t understand how I can use this in a method... How am I going to manipulate this object being a parameter of a method? Do you understand my doubt? P
– mrlucasrib
I really don’t understand no, rs.. You use it within a method just as if you instantiated it within the method, only in that case it was instantiated somewhere else. Like primitives, you can create a new int within a method, or you can take one per parameter.
– Math