[an error occurred while processing this directive]
[an error occurred while processing this directive]public class TvTest { public static void main(String[] args){ long l = System.currentTimeMillis() ; System.out.println("lastModofied: " + Long.toHexString(l)); } }
#include <sys/time.h> int main(void){ struct timeval tv; long long int jtv; gettimeofday(&tv, 0); jtv = tv.tv_sec * 1000; jtv += (tv.tv_usec / 1000); printf("Java style: %16llx\n", jtv); }
class Oya {
class Kodomo {
void f(){
Oya.this;
}
}
}
String str = Integer.toHexString(0x100 + i); str.subString(1);とします。javaにはsprintfがないし、DecimalFormatは"Decimal"だから10進数しか使えないし。
import java.io.*; import java.awt.*; public class Col { static String getColStr(float r, float g, float b){ String str = Integer.toHexString((1<<24) + ((int)r <<16) + ((int)g<<8) + (int)b); return str.substring(1); } public static void main(String[] args){ System.out.println("<html><body>"); for(float s = 0.0f; s <= 1.0f; s += 0.2f){ System.out.println("s=" + s + "<table><tr>"); for(float v = 0.2f; v <= 1.0f; v += 0.2f){ System.out.println("<tr>"); for(float h = 0.0f; h < 1.0f; h += 0.1f){ Color cl = Color.getHSBColor(h, s, v); String str = getColStr(cl.getRed(), cl.getGreen(), cl.getBlue()); System.out.println("<td style='width:60px;background-color:#" + str + "'>"+ str + "</td>"); } System.out.println("</tr>"); } System.out.println("</table><br />"); } System.out.println("</body></html>"); } }出力したHSVマップ
import java.io.*; import java.util.*; public class Te{ public static void main(String[] args){ Map<String, Integer> hm = new HashMap<String, Integer>(); hm.put("kei", 10); hm.put("mei", 2); hm.put("rei", 8); Set<Map.Entry<String, Integer>> s = hm.entrySet(); for(Map.Entry<String, Integer> e : s){ System.out.println("key \t: " + e.getKey()); System.out.println("value \t: " + e.getValue()); } SortedSet<Map.Entry<String, Integer>> ss = new TreeSet<Map.Entry<String, Integer>> (new Comparator<Map.Entry<String, Integer>>(){ public int compare(Map.Entry<String, Integer> e0, Map.Entry<String, Integer> e1) {return(e0.getValue() - e1.getValue()); } public boolean equals (Object o) {return (super.equals(o));} }); s.addAll(s); for(Map.Entry<String, Integer> e : ss){ System.out.println("key \t: " + e.getKey()); System.out.println("value \t: " + e.getValue()); } } }
key : rei value : 8 key : mei value : 2 key : kei value : 10