Skip to content

Commit b1290c8

Browse files
authored
Update MyAwesomProgram.java
1 parent 431c268 commit b1290c8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Classes/Fields2Class/MyAwesomProgram.java

+18
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,21 @@ public static void main(String [] args)
3131
//Bob Smith
3232
}
3333
}
34+
35+
//<-------------CHANGING THE ABOVE CODE TO THE BOTTOM CODE TO CALL THE OUTPUT METHOD ON USER FROM A STRING VARIABLE!------------->
36+
public class MyAwesomeProgram
37+
{
38+
public static void main(String [] args)
39+
{
40+
User user = new User();
41+
user.firstName= "Bob";
42+
user.lastName= "Smith";
43+
44+
String message = user.output();
45+
46+
System.out.println(message);
47+
48+
}
49+
}
50+
//Remember whenever I have the keyword void within my method declaration
51+
//I can still use the return keyword within it but I cannot return a value.

0 commit comments

Comments
 (0)