473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

int can't be dereferenced

281 100+
Good Day!
How to tackle 'int can't be dereference'?. What does it mean?
Please give me some pointer....thanks guys

Expand|Select|Wrap|Line Numbers
  1. public static void main(String[] args) 
  2.     {
  3.          int opcode = GCD; 
  4.  
  5.          String out="";
  6.  
  7.         int b2 = 300;
  8.         int b1 = 700;
  9.  
  10.          switch (opcode) 
  11.          {           
  12.             case GCD:       out = b1.gcd(b2).toString(); // THE ERROR COMES FROM HERE....
  13.                             break;
  14.             default:        throw new BigAlException("invalid operation");
  15.         }
  16.  
  17.           System.out.println(out);
Mar 31 '07 #1
7 3050
r035198x
13,262 8TB
Good Day!
How to tackle 'int can't be dereference'?. What does it mean?
Please give me some pointer....thanks guys

Expand|Select|Wrap|Line Numbers
  1. public static void main(String[] args) 
  2. {
  3. int opcode = GCD; 
  4.  
  5. String out="";
  6.  
  7. int b2 = 300;
  8. int b1 = 700;
  9.  
  10. switch (opcode) 
  11. case GCD: out = b1.gcd(b2).toString(); // THE ERROR COMES FROM HERE....
  12. break;
  13. default: throw new BigAlException("invalid operation");
  14. }
  15.  
  16. System.out.println(out);
b1.gcd(b2).toString b1 is an int and you are trying to call a method on it! Remember you can only call methods on objects not on primitives.
Mar 31 '07 #2
shana07
281 100+
b1.gcd(b2).toString b1 is an int and you are trying to call a method on it! Remember you can only call methods on objects not on primitives.
How should I do to call gcd method by parsing int b1 and int b2?
Mar 31 '07 #3
r035198x
13,262 8TB
How should I do to call gcd method by parsing int b1 and int b2?
Wrap then in BigInteger
Mar 31 '07 #4
shana07
281 100+
Wrap then in BigInteger
such this?
Expand|Select|Wrap|Line Numbers
  1. BigInteger b1=null, b2=null;
  2.  
  3.         b2 = receiveNumber(arrayArgs[1]);
  4.         b1 = receiveNumber(arrayArgs[0]);
btw, is there any gcd method in integer java core class? I mean no BigInteger?
Is like I want to skip BigInteger..
Mar 31 '07 #5
r035198x
13,262 8TB
such this?
Expand|Select|Wrap|Line Numbers
  1. BigInteger b1=null, b2=null;
  2.  
  3. b2 = receiveNumber(arrayArgs[1]);
  4. b1 = receiveNumber(arrayArgs[0]);
btw, is there any gcd method in integer java core class? I mean no BigInteger?
Is like I want to skip BigInteger..
You can always check the docs. Does your receiveNumber method return a BigInteger?
Mar 31 '07 #6
shana07
281 100+
You can always check the docs. Does your receiveNumber method return a BigInteger?
it does....
Expand|Select|Wrap|Line Numbers
  1.  BigInteger b = null;
  2.  
  3.         b = new BigInteger(str);  
  4.         return b;
I am just wondering, is there any normal gcd (int a, int b) in other java core class as this method calls BigInteger gcd.....
Mar 31 '07 #7
r035198x
13,262 8TB
it does....
Expand|Select|Wrap|Line Numbers
  1.  BigInteger b = null;
  2.  
  3. b = new BigInteger(str); 
  4. return b;
I am just wondering, is there any normal gcd (int a, int b) in other java core class as this method calls BigInteger gcd.....
You should just write your own method.
Apr 2 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Geoff | last post by:
Hey.. I'm having problems with stopping this timer from outside the 'runTimer()' class.. i have no problems calling 'cancel()' from inside the run() method but I want to be able to stop the Timer...
7
by: Sean J. Fraley | last post by:
This code illustrates what I'm confused about: template<typename T> class foo { public: template<typename U> void fooFunction(const foo<U>& x) {
6
by: B. Penn | last post by:
Hi, I was testing pointers and found that I could still dereference a pointer and access the value/variable it pointed to after deleting it, which confused me for "the variable it pointed to is...
14
by: bo | last post by:
And why and where one should use one vs. the other? Verbally, it seems like semantics to me--but obviously there is some actual difference that makes references different and or preferable over...
26
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function...
27
by: Chess Saurus | last post by:
I'm getting a little bit tired of writing if (a = malloc(...) == NULL) { // error code } I mean, is it really possible that a malloc call could fail, except in the case of running out of...
8
by: G Patel | last post by:
Hi, As the FAQ and several clc post warn again, I know it's not legal to use a pointer to step outside the bounds of an array (except one past the last element, and that pointer must never be...
11
by: grocery_stocker | last post by:
How come you can subtract pointers, but you cannot add them?
7
by: shanemh | last post by:
I'm starting out with c++ and for some reason I cant get my brain around this one: If I have the following: void Foo (someClass& x) {} int Main (void) {
2
by: blknmld69 | last post by:
I would like to know how can I use the stringValueOf to remove this error: double cannot be dereferenced gradeCalc.noOfStudents = inFile.nextInt(); // get the number of Students ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.