Sinisterly
My java code - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Java, JVM, & JRE (https://sinister.li/Forum-Java-JVM-JRE)
+--- Thread: My java code (/Thread-My-java-code)

Pages: 1 2


RE: My java code - Master - 02-28-2015

(02-28-2015, 05:40 AM)Strawberry Wrote: What was your reasoning behind creating the two strings "and" & "has" instead of just printing everything out like this?

System.out.println("Richest users are " +usernames[0][1] + "and" + usernames[1][1]);
System.out.println(usernames[0][1] + "has" + amount[0][0]);
System.out.println(usernames[1][1] + "has" + amount[0][1]);

It show as an error on netbeans when I did your way.


RE: My java code - Strawberry - 02-28-2015

Attempting to compile the following code does not give me any errors.

Code:
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Sinister { public static void main (String[] args) throws java.lang.Exception { String[][] usernames= { {"Blunt", "Eclipse", " Oni"}, {"Tarew", " Master", " Lux"} }; String[][] amount= { {"86", "59", "46"} }; System.out.println("Richest users are " +usernames[0][1] + " and " + usernames[1][1]); System.out.println(usernames[0][1] + " has " + amount[0][0]); System.out.println(usernames[1][1] + " has " + amount[0][1]); } }