Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Ketan Dave   on May 12 In Java Category.

  
Question Answered By: Ralph Murray   on May 12

actually compiled fine for me once I got jmav compiled. Just
a warning about not using frisky.send statically.

jmav, on the other hand...why are you passing anything to the
constructor? neither john nor jmav have any members. In your
constructor, you are trying to assign values to the two ints privately
declared in john's main. jmav has no access to these vars and it
doesn't need it.

Anyways, classes can have multiple constructors. Java will use the
appropriate one based on what you pass in.

code:

public class  john {
// This code  not changed
}

public class jmav{
jmav() {}
jmav(int n1, int  n2) {}
public static  void send(int n1, int n2) {
System.out.println("The numbers  are " + n1 + " and " + n2);
}
}

Share: