![]() |
|
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
|
My java code - Master - 02-02-2015 I started learning java here some code I wrote. Code: 1| String[][] usernames= {
2| {"Blunt", "Eclipse", " Oni"},
3| {"Tarew", " Master", " Lux"}
4| };
5|
6| String[][] amount= {
7| {"86", "59", "46"}
8| };
9|
10| String and = " and ";
11| String has = " has ";
12|
13| System.out.println("Richest users are " +usernames[0][1] +and + usernames[1][1]);
14| System.out.println(usernames[0][1] +has + amount[0][0]);
15| System.out.println(usernames[1][1] +has + amount[0][1]);
16| };Code: Richest users are Eclipse and Master
Eclipse has 86
Master has 59RE: My java code - ねこまっしぐら - 02-02-2015 Cool, I'm on that list. Just wait until I'm top. RE: My java code - Alex - 02-02-2015 (02-02-2015, 01:28 PM)Johnny Wrote: Cool, I'm on that list. Just wait until I'm top. Not on my watch fgt. RE: My java code - Blunt - 02-02-2015 (02-02-2015, 01:28 PM)Johnny Wrote: Cool, I'm on that list. Just wait until I'm top. Agree with Alex, no Europol agent will be the richest user as long as I fucking live. Good job though @Master RE: My java code - Eclipse - 02-02-2015 You should connect to the site and read the richest user instead of typing it into the code. RE: My java code - Master - 02-02-2015 (02-02-2015, 08:59 PM)Eclipse Wrote: You should connect to the site and read the richest user instead of typing it into the code. Great idea how would you do it. RE: My java code - Eclipse - 02-02-2015 Read page html. Find relevant part. Get data. Print in proper format. RE: My java code - phyrrus9 - 02-03-2015 I wouldn't do it in Java, afaik sockets are a PITA. But if you know how to use them, just match a regex start looking when this is matched: Code: </table><br/>
<table border="0" cellspacing="0" cellpadding="5" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>Richest Users</strong></td>
</tr>
<tr>
<td class="tcat" width="50%"><strong>User</strong></td>
<td class="tcat" width="50%" align="center"><strong>Amount</strong></td>
</tr>then, follow this format: Code: <tr>
<td class="trow1" width="50%"><a href="{link here}">{username}</a></td>
<td class="trow1" width="50%" align="center">{amount}</td>
</tr>RE: My java code - m1kep - 02-11-2015 (02-03-2015, 12:45 AM)phyrrus9 Wrote: I wouldn't do it in Java, afaik sockets are a PITA. But if you know how to use them, just match a regexFrom personal experience and what others have said, regex tends to be the overly complicated way of parsing html, especially when you need to find lots of specific elements and such But regex could be used for this kind of stuff, just wanted to throw that it there that you probably shouldn't use overly complicated regular expressions for complex html parsing RE: My java code - Strawberry - 02-28-2015 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]); |