public class deck
{
public static void main(String[] args)
{
edward test = new edward();
System.out.print(test);
}
}
1 edward test.
2 print . API Java, print(Object)
. , String.valueOf(Object), , , write(int).
, : edward@672563. , String.valueOf(obj) obj (edward), @, obj (672563).
, , :
public class Deck
{
public static void main(String[] args)
{
Edward test = new Edward();
test.message();
}
}
public class Edward
{
public void message()
{
System.out.print("hello, this is text!");
}
}
On the line, 1you call the method test message(). The method call executes the code that is in this method, therefore it test.message()executes the line
System.out.print("hello, this is text!");
Here is another way to do the same:
public class Deck
{
public static void main(String[] args)
{
Edward test = new Edward();
System.out.println(test.message);
}
}
public class Edward
{
public String message = "hello, this is text!";
}
In the line, 2you create a new field Stringwith a value "hello, this is text!". In the line, 1you print the value of the field messagecontained in the object test.
If there are other parts of this code that you don’t understand, feel free to comment on this answer!