-2

I have two files first one is

Welcome.java

package com.project;

import com.code.*;

class Welcome {
    public static void main(String[] args) {
        Test t = new Test();
        System.out.println("the valus is " + t.addition(4,3));
    }
}

Test.java

package com.code;

public class Test {
    private int a;
    private int b;
    public Test() {
        a=2;
        b=3;
    }

    public int addition(int a, int b) {
        return a+b;
    }
}

When I compile Welcome.java I got:

error: cannot find symbol

System.out.println("the valus is " + t.addition(4,3));

Cannot find the reason why ? help please

Edit:

I compile with this command:

javac com/project/Welcome.java

Solution:

javac -cp com/code/* com/project/Welcome.java

Martin.B
  • 7
  • 2

1 Answers1

2

At Test, the addition method should be public int addition(int a,int b)

Or251
  • 196
  • 10