Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ProgramName{
- public static void main(String args[]){
- //canonical entry point for application
- }
- }
- looping:
- while(condition){
- // dostuff
- }
- //loop through everything in a collection. This case it's args.
- for(String text : args){
- System.out.println(text);
- }
- if(condition){
- //do stuff
- }
- else{
- //otherwise
- }
- Else is optional. Remember dangling else though!
- //here's a simple person class, as if you took it from an SQL server.
- public class Person{
- private int IDNumber;
- private String fName;
- private String lName;
- private String pNumber; // really, you mostly treat these things as strings anyway, so why the fuck not?
- public Person(int IDNumber, String firstName, String lastName, String phoneNumber){
- this.IDNumber = IDNumber; //this refers to this class' member, as opposed to the one in the method call.
- fName = firstName;
- lName = lastName;
- pNumber = phoneNumber;
- }
- private Person(); // this means you can't call new Person() outside this class.
- public toString(){
- return fName + " " + lName + " Phone: " + pNumber + "\nInternalID: " +_IDNumber;
- }
- }
- you can now create Person objects with new Person(idNumber, "first name", "last name", "phone number"); but note that nothing validates the phone number.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement