Skip to content

Instantly share code, notes, and snippets.

@544
Last active August 29, 2015 13:57
Show Gist options
  • Save 544/9413332 to your computer and use it in GitHub Desktop.
Save 544/9413332 to your computer and use it in GitHub Desktop.
JavaでFizzBuzzする環境を整える。 ref: http://qiita.com/544/items/b00d9a566100ca613b24
brew install maven
mvn archetype:generate
mvn compile
java -classpath target/classes test.FizzBuzz
package test;
public class FizzBuzz {
public static void main(String[] args) {
String val = null;
for(int i=1; i<100; i++) {
if (i%15 == 0) {
val = "FizzBuzz";
} else if (i%3 == 0) {
val = "Fizz";
} else if (i%5 == 0) {
val = "Buzz";
} else {
val = String.valueOf(i);
}
System.out.print(val);
System.out.print(" ");
}
}
}
[masato@mba] $ tree
.
├── pom.xml
└── src
├── main
│   └── java
│   └── test
│   └── App.java
└── test
└── java
└── test
└── AppTest.java
7 directories, 3 files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment