I'm completely new to java, would like some help.
I have a class named class1 and within the class are 2 functions f1() and f2()
I take a number as input in f1(). I would like to have that number in f2() as well.
I did this by returning the number from f1() to main and then accessing the same from f2() but then I tried to do the same with a number and an array together at the same time and failed.
Can someone please help me out, I need to have the array and number which are initialized to appropriate values in f1() to be available to me in f2()
Thanks in advance. :)
chetanbasuray
1
Junior Poster in Training
Recommended Answers
Jump to PostNot sure what you're looking for...perhaps you could provide examples of the method calls that evidently did not work?
Or try something like this:
public class Class1 { private int[] input; public void f1(int input) { f1(new int[] {input}); } public void f1(int[] input) { this.input …
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.