#Why is this an error?

1 messages · Page 1 of 1 (latest)

zinc pewter
#

Please help thank you. ```java public static void main(int[] args) {

if (capacity <= 99) {
    System.out.println("Island still has capacity");
}
else if (capacity >= 100) {
    System.out.println("Island is full");
}

}

}```

steady moonBOT
#

<@&987246399047479336> please have a look, thanks.

steady moonBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

long crane
#

u forgot to share the error

zinc pewter
#

Your right lol

long crane
#

but most likely its ur typo int[] args

#

instead of String[] args

zinc pewter
long crane
#
  • int should be string
  • u never defined what c is
  • u never defined what capacity is
  • u didn't create a class around this method
long crane
zinc pewter
#

I have

long crane
#

impossible

#

copy paste the full file

#

Island.java

zinc pewter
#

import java.util.ArrayList;

public class Island 
{
// import the ArrayList class
ArrayList<String> PassOB = new ArrayList<String>(); // Create an ArrayList object
    
    private String name;
    private int luxuryRating;
    private int capacity;
    private int passId;
    private int islandNO;

public Island(int luxuryRating, int capacity, int passId)
   {
       luxuryRating = 0;
       passId = 0;
       capacity = 0;
       islandNO = 0;
   }
   
public Island(String n)
   {
       name = n;
   }
    
    
    public static void main(String[] args){
    ArrayList<String> PassOB = new ArrayList<String>();
    PassOB.add("Name");
    PassOB.add("Luxury Rating");
    PassOB.add("Capacity");
    PassOB.add("passId");
    System.out.println(PassOB);
    
    
}

public int GetIslandNo()
    {
        return islandNO;
    }

public int GetRating()
    {
        return luxuryRating;
    }
    
public int GetCapacity()
    {
        return capacity;
    }  
    
public String GetName()
    {
        return name;
    }
    
    public static void main(int[] args) {

        
    if (capacity <= 99) {
        System.out.println("Island still has capacity");
    }
    else if (capacity >= 100) {
        System.out.println("Island is full");
    }
    
}


}```
steady moonBOT
zinc pewter
#

No I meant I have made the class

long crane
#

u already created a main method. why do u want to create another

#

very odd

#

when do u want to execute this code? whenever a new island is created?

#

or when a certain method is called?

#

or when the program starts?

#

right now ur new code makes no sense

zinc pewter
#

Well I want it when the island is full

#

So if it = over 100

#

Or less

long crane
#

that's not what i mean

#

ur describing the code logic itself

#

but I'm asking for the placement

#

when should that check be done

#

whenever a new island is created?

#

whenever u get the current capacity?

#

whenever you u change the capacity?

#

whenever the program starts?

#

when it ends?

#

u dont really seem to understand the code ur writing. at least not its flow

#

like in what order and when which part of ur code is executed

gray goblet
#

@zinc pewter