Add the following comment block at the top of the file (cut and paste! don't retype the whole thing). Fill it in with your name (family names, given names), and your student number. Read the declaration.
/**
* Name: Last Name, First Name
*
* Student Number: xxxxxxxxx
*
* Declaration: I hereby assert that this application was written by me. I
* understand that it is a violation of the Senate Policy on Academic
* Honesty for me to submit someone else's work without identifying it as
* such and that this is a form of cheating. I also understand that if it is
* discovered that I have committed a breach of Academic Honesty for
* cheating or any other charge, then the full extent of available penalties
* may be brought against me.
*
*/
The class System has a service that will report the name of the user who is running the current application.
This method is static and its API is:
String getProperty(String key)
Read the description of the method in Lab2.7 (p87 3ed, p91 3rd ed) (BUT DON'T DO WHAT THE LAB L2.7 SAYS - JUST READ THE BACKGROUND PART)
Declare a variable with the name myName. It should be of type String.
Invoke the method. The method has one parameter that is a String and is called "key". Use the value "user.name" for the key.
Lab L2.7 has an example of invoking the method (although with a key that has different value).
Assign the value of the return of the method getProperty to the variable myName.
Print out the value of the variable myName to the console.
- To run Check02P, select Run -> Run As -> Java Application.
- The output will appear in the console.
- The green circle with the right triangle arrow in the menubar is the shortcut.
The output will look something like this (but the name will be your cseXXXXX login, not the string cseXXXXX exactly)
