Chris Yates

Greenhorn
+ Follow
since Sep 21, 2015
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Yates

I thought i had to write a for loop to go through all of the elements in a Vector but it turns out toString() of Vector already does that. Usually by default they print some weird numbers, references i believe, why is it not the sace with Vector? How could have i guessed this? -.-
8 years ago




I can call super here with c right? No need for cast of Car c to Vehicle, iam i right?
8 years ago
Suppose i have two classes Vehicle and subclass Car.
In car i have this copy constructor which takes Car as parameter.



Can i call super with c or does it need cast to Vehicle? I would like to know details of this behinds the scenes.
Thanks.
8 years ago

Matthew Brown wrote:It should return "int", but the method also should be marked as static. When you see a method declared as "static int", only the "int" part is the return type. The "static" means that you don't need to create an instance of the class to call the method.



Oh i see. But then why is it not common practice to declare all getters static?
8 years ago
When you write a getter for a variable that is static say static int should the method return just int or since it's static variable it should return static int? Or no difference?
8 years ago
Hi, i'am just a newbie learning java and many times when i have doubts i search google and with an example i can get going. However as i learn more things i started to notice that code gets complicated, without much organization, now i have to think how all the classes will intereact with each other.
So i'd like to know if there is sites out there with java code of applications so that i can take a look at it and see how other people do it and what i'am doing wrong. I think exposure to code from other people would be really beneficial for me at this particular moment but i'am not aware of the existence of such sites.
Appreciate any help, Chris.
8 years ago
That's pretty cool, thanks!
8 years ago
I saw this line of code to parse a calculation giving as a String such as "15+15".
i

Can someone explain what it does in detail?
8 years ago
Is there a faster way after filling array of array of char to convert it to String array? Instead of looping like i did? I know its possible to give char array in constructor but doesnt seem to work with char[][].

8 years ago
So API is not same as interface :| API is all the methods an object has to comunicate with other objects. What is the interface?
8 years ago
Is it correct to say that an object interface is the methods that the object has to communicate with the outside world? Or it's something more than this?
How you would you briefly define what it is?
8 years ago


Why is this wrong in java?
8 years ago
That was just to show my doubts. Now i know that after calling a settor with a string in main function changing that string later won't change the object because the field in the object still points to the string used in the settor. There was some confusion in my head but now it's all clear, thanks for help.
8 years ago
I'd like to know what happens behind the scenes with this call in main and this settor. So in main a have some object of class Vehicle and i want to set its name i also have some strings.





Now here's my doubt. When i do ; honda gets the name civic. if i then in main do s1 = s2, s1 now points to "concerto" but the honda object still prints civic. I thought when i did setName the variable was pointing to s1 but it seems that instead it does a copy?
8 years ago
They were indeed private fields. So whenever i want to acess something private from another class getters and setters is the way to go?
Now if i'am printing a field specific to that class. In above eample in class ToyotaSupra if i want to print the color it doesnt matter which way i go, i can use getters and this, right?
8 years ago