Results 1 to 2 of 2
  1. #1
    Torgero is offline Member
    Join Date
    Oct 2008
    Rep Power

    Default Trying to make a return....

    This is the code

    Java Code:
    class Circle {
    	private double radius;
    		public sirkel(double startRadius) {
    		radius = startRadius;
    		public double finnAreal() {
    		return Math.PI * radius * radius;
    		public double findcircuit() {
    		double omkrets = 2.0 * Math.PI * radius;
    		return omkrets;
    		class test{
    		public static void main (String [] args){
    			double finncircuit (2);
    This is the error message:

    D:\Java\Java for alle\ invalid method declaration; return type required
    public sirkel(double startRadius) {
    D:\Java\Java for alle\ ';' expected
    double finncircuit (2);
    2 errors

    Tool completed with exit code 1

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Rep Power

    Default misspell

    Many things wrong...
    • You're calling method "finncircuit" and the name of the method is "findcircuirt"
    • You're trying to call a method (findcircuit) that's in another class (Circle). You need to instantiate the Circle class to be able to call the findcircuit method
    • You're not assigning the return value from the call to the findcircuit to a double type variable.
    • You haven't defined the findcircuit method receiving any arguments
    • If you want the radius variable to have a value (and not send it as an argument), you have to have a constructor that sets it.

    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. Using int/int, 7/5 would return 1
    By zoe in forum New To Java
    Replies: 2
    Last Post: 12-02-2008, 11:25 AM
  2. about 'return'.
    By helloworld in forum New To Java
    Replies: 9
    Last Post: 11-28-2008, 04:08 AM
  3. how do i make a string return a number?
    By pjr5043 in forum New To Java
    Replies: 6
    Last Post: 09-15-2008, 04:56 AM
  4. return out of scope?
    By another_steve in forum New To Java
    Replies: 5
    Last Post: 01-28-2008, 09:34 PM
  5. if..else..return
    By mqdias in forum New To Java
    Replies: 1
    Last Post: 08-10-2007, 04:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts