2 ms·
Hello world in Swing: (from here: http://www.java2s.com/Code/Java/Swing-JFC/HelloWorldSwing.htm http://www.java2s.com/Code/Java/Swing-JFC/HelloWorldSwing.ht...
by steveklabnik 16y ago
Hello world in Swing: (from here: http://www.java2s.com/Code/Java/Swing-JFC/HelloWorldSwing.htm http://www.java2s.com/Code/Java/Swing-JFC/HelloWorldSwing.ht... )
import javax.swing.JFrame;
import javax.swing.JLabel;
public class HelloWorldSwing {
public static void main(String[] args) {
JFrame frame = new JFrame("HelloWorldSwing");
final JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
Hello world in Shoes:
Shoes.app do
para "Hello, world"
end
Hello world for Hibernate: (from here: http://www.javaworld.com/javaworld/jw-10-2004/jw-1018-hibernate.html http://www.javaworld.com/javaworld/jw-10-2004/jw-1018-hibern...)
package hello;
public class Message {
private Long id;
private String text;
private Message nextMessage;
private Message() {}
public Message(String text) {
this.text = text;
}
public Long getId() {
return id;
}
private void setId(Long id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Message getNextMessage() {
return nextMessage;
}
public void setNextMessage(Message nextMessage) {
this.nextMessage = nextMessage;
}
}
Session session = getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
Message message = new Message("Hello World");
session.save(message);
tx.commit();
session.close();
The equivalent in ActiveRecord:
class Message < ActiveRecord::Base
end
message = Message.new(:text => "Hello, world")
message.save
You have to set up your schema in both, so I've left that out.
These are just the first two that came to my head. I ditched Java so long ago that I'm sure a few hundred more have come up.