Last active
August 29, 2015 13:57
-
-
Save 544/9413332 to your computer and use it in GitHub Desktop.
JavaでFizzBuzzする環境を整える。 ref: http://qiita.com/544/items/b00d9a566100ca613b24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install maven |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mvn archetype:generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mvn compile | |
java -classpath target/classes test.FizzBuzz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(" "); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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