package org.cs212.hello;
public class Hello {
public static void main(String[] args) {
int a = 5;
int b = 5;
if (a==b)
System.out.println("a equals b");
Integer A = new Integer(5);
Integer B = new Integer(5);
if (A.equals(b))
System.out.println("A equals B");
/*
String s = "Goodbye";
System.out.println(s);
String t = "Good";
t = t + "bye";
System.out.println(t);
System.out.println(s == t);
if (s.equals(t))
{
System.out.println("They are equal!");
}
System.out.println("hello");
Person p = new Person();
p.setName("Fred");
System.out.println(p.getName());
Person q; // = new Person();
//q.setName("Fred");
q = p;
if(p==q)
{
System.out.println("same");
}
else
{
System.out.println("different");
}*/
}
}
Wednesday, June 30, 2010
public class Person
{
// fields
private String name; // the person's name
private int maximumBooks;
// constructor
public Person()
{
name = "unknown name";
maximumBooks = 3;
}
qccs212.blogspot.com
// getters and setters
public String getName()
{
return name;
}
public void setName(String n)
{
name = n;
}
public int getMaximumBooks() {
return maximumBooks;
}
public void setMaximumBooks(int maxBooks) {
maximumBooks = maxBooks;
}
}
{
// fields
private String name; // the person's name
private int maximumBooks;
// constructor
public Person()
{
name = "unknown name";
maximumBooks = 3;
}
qccs212.blogspot.com
// getters and setters
public String getName()
{
return name;
}
public void setName(String n)
{
name = n;
}
public int getMaximumBooks() {
return maximumBooks;
}
public void setMaximumBooks(int maxBooks) {
maximumBooks = maxBooks;
}
}
Subscribe to:
Posts (Atom)