Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Accessing methods HELP! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Accessing methods HELP!" Watch "Accessing methods HELP!" New topic
Author

Accessing methods HELP!

Naf Rash
Ranch Hand

Joined: Feb 19, 2004
Posts: 85
How do you access/invoke a method from another class? Please could you provide an example.
David Maddox
Greenhorn

Joined: Feb 25, 2004
Posts: 12
ok here is an example
public class Dog{
public void bark(){
}
}

public class dogTest{
Dog dog= new Dog(); /*you create a dog object and it has all of its methods/*
dog.bark();
}
[ February 26, 2004: Message edited by: David Maddox ]
[ February 26, 2004: Message edited by: David Maddox ]
Naf Rash
Ranch Hand

Joined: Feb 19, 2004
Posts: 85
I think that you may have forgotten to post the example! Thanks.
Naf Rash
Ranch Hand

Joined: Feb 19, 2004
Posts: 85
Ignore what I just said for some reason the code did not load earlier on. Sorry.
David Maddox
Greenhorn

Joined: Feb 25, 2004
Posts: 12
yeah i hit the wrong button
 
GeeCON Prague 2014
 
subject: Accessing methods HELP!