Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

User Defined Package Doubts

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All

Iam trying to create a user defined package MyPack
Iam encountering a problem :

MyOperation m=new MyOperation(); --- Cannot resolve symbol..
plz go thru the codes and tell me how to solve the errors...

MyOperations.java

package MyPack;

public class MyOperation
{
public int add(int a, int b)
{
int c;
c=a+b;
return c;
}
public int sub(int d,int e)
{
int f;
f=d-e;
return f;
}
public int mul(int g,int h)
{
int i;
i=g*h;
return i;
}
public int div(int j,int k)
{
int l;
l=j/k;
return l;
}
}

MyCalculation.java

import MyPack.*;

public class MyCalculation
{
public static void main(String args[])
{
int n1,n2,n3,n4;
MyOperation m=new MyOperation( );
n1=m.add(50,5);
n2=m.sub(40,5);
n3=m.mul(7,8);
n4=m.div(10,10);
System.out.println("The Value of n1 is"+n1);
System.out.println("The Value of n2 is"+n2);
System.out.println("The Value of n3 is"+n3);
System.out.println("The Value of n4 is"+n4);
}
}



I have compiled "MyOperations.java"...problems is in "MyCalculation.java".
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i trie this:

before, i created two folders inside my root(raiz, in my case), called MyMain (this one will contain MyCalculation) and MyPack
to MyCalculation i made:

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic