473,405 Members | 2,261 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,405 software developers and data experts.

General Java Help

Steel546
Heyyy, I'm back. Getting the hang of this java thing. Anyways, I have a few questions, I'll leave my hardest for last.

So, I believe I'm having an overloading method issue here.

Expand|Select|Wrap|Line Numbers
  1. public static boolean closeAccount (double acctBalance, int checksLeft) {
  2.     // returns true if acctBalance is less than zero or checksLeft is less than or equal to zero.
  3.  
  4.     if (acctBalance < 0 || checksLeft <= 0){
  5.         return true;}
  6.         else{
  7.             return false;
  8.         }
  9.     }
  10.  
  11. }
  12. *public static boolean closeAccount (int acctBalance, int checksLeft) {
  13.     // returns true if acctBalance is less than zero or checksLeft is less than or equal to zero.
  14.  
  15.     if (acctBalance < 0 || checksLeft <= 0 ){
  16.  *       return true;}
  17.     else{
  18.  *       return false;
  19.     }
  20.  
  21. }
I'm getting a "class, interface, or enum expected" error on the lines with asterisks. I'm creating overloading methods, but I believe that as long as the arguments are different, then I'm okay. I have a double/int in the first (fine) and a int/int in the second. Little confused.

And lastly... how do you launch a browser? I've been searching, and there seems to be no basic answer to this.

Expand|Select|Wrap|Line Numbers
  1. import com.apple.mrj.MRJFileUtils;
  2. import java.io.*;
  3.  
  4. public class Main {
  5.  
  6.   String url = "http://www.google.com/";
  7.  
  8.     public static void main(String[] args) {new
  9. Open();
  10.     }
  11. Open() {
  12. try {
  13. MRJFileUtils.openURL(url);
  14. } catch (IOException ex) {}
  15.   }
  16.  
  17.  
  18.     }
Man... that's ugly. Anyways, but that's for a Mac. Instead, I'm trying to make a method to call instead of putting it under the main argument. Anywho, I'll keep working on that one. As always, any suggestion is greatly appreciated.
Mar 24 '09 #1
4 1566
Wait, found something.

Expand|Select|Wrap|Line Numbers
  1. URLDisplayer.getDefault().showURL(URL url);
Mar 24 '09 #2
Nevermind, fixed it.

Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2.  
  3. public class KyleTaylorToolBox {
  4.  
  5.     public static void printEveryXtoY (int x, int y) {
  6.    // this method prints every xth integer from 0 to y that is less than or equal to y.
  7.    // example output when passed (4,14): 0  4  8  12
  8.    // example output when passed (2, 14): 0  2  4  6  8  10  12  14
  9. int count = 0;
  10.           while (count <= y) {
  11.                System.out.println( + count);
  12.                count = count + x;
  13.           }
  14.  
  15.  
  16.     }
  17.  
  18.  public static void launchBrowser ( ) throws IOException {
  19.     // this method starts a web browser like Internet Explorer. Search the Internet for help.
  20.  String url="http://www.cse.unt.edu";
  21.  Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
  22.  
  23.  
  24.  }
  25.  
  26. public static boolean isOdd (int x) {
  27.     // this method returns true if x is odd and false if x is even.
  28.     if (x % 2 == 0){
  29.         return false;}
  30.         else{
  31.             return true;
  32.         }
  33.     }
  34.  
  35. //Create two overloaded methods called closeAccount:
  36.  
  37. public static boolean closeAccount (double acctBalance, int checksLeft) {
  38.     // returns true if acctBalance is less than zero or checksLeft is less than or equal to zero.
  39.  
  40.     if (acctBalance < 0 || checksLeft <= 0){
  41.         return true;}
  42.         else{
  43.             return false;
  44.         }
  45.     }
  46.  
  47. public static boolean closeAccount (int acctBalance, int checksLeft) {
  48.     // returns true if acctBalance is less than zero or checksLeft is less than or equal to zero.
  49.  
  50.     if (acctBalance < 0 || checksLeft <= 0 ){
  51.         return true;}
  52.     else{
  53.         return false;
  54.         }
  55.  
  56.     }
  57. }
  58.  
  59.  

Okay. Now I'm having problems calling the methods in a different class. Says "cannot find symbol".
Mar 25 '09 #3
sukatoa
539 512MB
You forgot to import KyleTaylorToolBox class in other class
Mar 25 '09 #4
JosAH
11,448 Expert 8TB
@Steel546
I'm sure 'it' said a lot more, e.g. the symbol it couldn't find and where it couldn't find it (including the line number). That should give you some clues.

kind regards,

Jos
Mar 25 '09 #5

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

Similar topics

2
by: Hmmm... | last post by:
For the most part I understand the VB "Language". I also understand C, C++, JAVA, JavaScript, etc, etc. What always holds me back is that I don't know what to do with them. I mean, I have good...
7
by: Chris | last post by:
Here's the situation: I work at a scientific institution and I have a portable electronic device which is used to take measurements. The device produces a very small amount of numerical data,...
1
by: GChong | last post by:
Hi, Im looking for some general 'marketing' info on dotnet: how long it has been in use (i.e first release date), how many companies are using it, number of .NET developers in the world,...
2
by: Alex | last post by:
Hello I am interested learn more about .NET but am uncertain of exactly what niche it fills in the world of programming. (The more I read the more I am confused). What I am looking for is the...
1
by: ralamo | last post by:
INSERT INTO ECN_1 (Old_SbPartNo, Old_PartDesc, Old_ManPartNo, Old_Manuf, Old_Vendor, Old_RefDesi, Old_Qty, New_SbPartNo, New_PartDesc, New_ManPartNo,New_Manuf, New_Vendor, New_RefDesi, New_Qty)...
6
by: Alex | last post by:
Hello I am intersting in developing and my background is VBA used in Excel and a brief intro to Java. I am interested in learning beyond VB and feel that C++ would be a very good language to...
8
by: Jolly Student | last post by:
Dear Colleagues: I am a systems guy who has been working with hardware, networking and basic scripting for ten years or so. I have been given the opportunity to attend ..Net classes of all...
4
by: ben.a.yates | last post by:
Hello, i have been an electronic engineer programmer for the last 15 years. In the early part of my career i was mainly a C programmer, but in the last 10 years or so i've done little programming....
2
by: mia23 | last post by:
Hello, I am a java beginner and I need series help in solving this program; my assignment is due after 2 days and I can't understand this program . This is THE PROGRAM:  The ABC medical clinic...
29
by: Dexter | last post by:
This Java based utility may be invoked from Java code to parse mathematical expressions. It is useful for programmers developing calculators, graphing utilities or other math related programs. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.