• Post Reply Bookmark Topic Watch Topic
  • New Topic

objects  RSS feed

 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



this topic is objective. i dont understand what? "Fruit fruit" stands for... how does it act. someone explain please
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to learn about how to create objects, with constructors. Look in the Java™ Tutorials, where it says "passing information" and about creating objects.
 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You need to learn about how to create objects, with constructors. Look in the Java™ Tutorials, where it says "passing information" and about creating objects.


also , why do i need two functions, init and print. cant i just do with one function ? print?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dmitri Makovetskiy wrote:
also , why do i need two functions, init and print. cant i just do with one function ? print?


Sure. You're the programmer. Do whatever you like.

Henry
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dmitri Makovetskiy wrote:also , why do i need two functions, init and print. cant i just do with one function ? print?

I'll be less extreme than Henry Methods should have a very restricted purpose. You would expect a method called "print" to print something, not to initialize an object.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you had one method that did what both init and print do...what happens if you want to init something and not print it? What happens inf you want to print something and not init it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!