java.awt.EventQueue.invokeLater(new Runnable() {
@Override
//myFrame is object of Window or JFrame
public void run() {
myFrame.toFront();
myFrame.repaint();
}
});
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
//myFrame is object of Window or JFrame
public void run() {
myFrame.toFront();
myFrame.repaint();
}
});
public static T[] concat(T[] first, T[] second) {
T[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;
}
For combining arbitrary number of arrays
BufferedImage myPicture = ImageIO.read(new File("path-to-file"));
JLabel picLabel = new JLabel(new ImageIcon( myPicture ));
add( picLabel );
:D
import java.io.*;
import java.net.*;
import java.util.*;
/**
* This program makes a socket connection to the atomic clock in Boulder,
* Colorado, and prints the time that the server sends.
*/
public class Time_Server_Socket_Test_Java {
public static void main(String[] args) {
try {
Socket s = new Socket("time-A.timefreq.bldrdoc.gov", 13);
try {
InputStream inStream = s.getInputStream();
Scanner in = new Scanner(inStream);
while (in.hasNextLine()) {
String line = in.nextLine();
System.out.println(line);
}
} finally {
s.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Mapmap = ...;
for (String key : map.keySet()) {
// ...
}
Method 2 :Pattern.quote() method lets you escape arbitrary text so it can be safely used in a regular expression."$5", you can match that exact string. Without escaping, the dollar sign would be interpreted as an end‑of‑line anchor. Use Pattern.quote() and the method wraps the text in \Q...\E quotes, ensuring every character is taken literally.Pattern.quote("$5");
import java.util.HashSet;
import java.util.Set;
/**
* Override_Annotation_Usage_Example, from Effective Java
*/
Method method = foo.getClass().getMethod("doSomething", null);
method.invoke(foo, null);