Skip to content

Instantly share code, notes, and snippets.

@edysegura
Last active August 29, 2015 14:05
Show Gist options
  • Save edysegura/370e99c3f946fc46bf10 to your computer and use it in GitHub Desktop.
Save edysegura/370e99c3f946fc46bf10 to your computer and use it in GitHub Desktop.
Groovy learning - Todo Case
public class Todo {
def name
def note
public static void main(String[] args) {
def todos = [
new Todo([name:'1', note:'One']),
new Todo([name:'2', note:'Two']),
new Todo([name:'3', note:'Three']),
new Todo([name:'4', note:'Four'])
]
todos.each {
println "${it.name} ${it.note}"
}
}
}
import java.util.List;
import java.util.ArrayList;
public class Todo {
private String name;
private String note;
public Todo() {}
public Todo(String name, String note) {
this.name = name;
this.note = note;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public static void main(String[] args) {
List<Todo> todos = new ArrayList<Todo>();
todos.add(new Todo("1", "One"));
todos.add(new Todo("2", "Two"));
todos.add(new Todo("3", "Three"));
todos.add(new Todo("4", "Four"));
for(Todo todo : todos) {
System.out.println(todo.getName() + " " + todo.getNote());
}
}
}
public class Todo {
def name
def note
}
def todos = [
new Todo([name:'1', note:'One']),
new Todo([name:'2', note:'Two']),
new Todo([name:'3', note:'Three']),
new Todo([name:'4', note:'Four'])
]
todos.each {
println "${it.name} ${it.note}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment