"Illegal modifier for the local class Shuffle1; only abstract or final is permitted"

edited October 2015 in Questions about Code

Trying to run the below code in Processing produces the above result. However, the exact same coding compiles and run perfectly in Eclipse. Can anyone explain why please?

The result should be "a-b c-d".

Martin

public class Shuffle1 {

  public static void main(String[] args) {
    int x = 3;
      while (x > 0) 
      {
        if (x > 2) {
          System.out.print("a");
        }

        x = x - 1;
        System.out.print("-");

        if (x == 2){
          System.out.print("b c");
        }

        if (x == 1){
          System.out.print("d");
          x = x - 1;
        }
      }
  }
}

Answers

  • edited October 2015

    http://forum.Processing.org/two/discussion/8045/how-to-format-code-and-text

    Processing's IDE (PDE) has a pre-processor which already concatenates all ".pde" files as 1 ".java" class.
    And that includes the public static void main(String[] args) {} stuff already! :(|)

    Take notice that all our classes become locally nested to the "invisible" sketch's top class too! ~:>

  • This will do the same thing in Processing

    void setup() {
      int x = 3;
      while (x > 0) 
      {
        if (x > 2) {
          System.out.print("a");
        }
    
        x = x - 1;
        System.out.print("-");
    
        if (x == 2) {
          System.out.print("b c");
        }
    
        if (x == 1) {
          System.out.print("d");
          x = x - 1;
        }
      }
    }
    
  • Thank you very much. That makes sense. However, when I run the code I get a small grey window with no text in it. Have I set the application up wrong?

    Martin

  • Answer ✓

    no

    processing is designed to display graphical output in that window. you're just not using it so it appears the default size and colour.

  • Thanks again for the information. Although not new to Java, you've probably guessed I'm new to Processing. As my Son is using this at his University I thought it would be good idea to learn to use it so I can help him out if needed.

Sign In or Register to comment.