Optional: If you have your own laptop, now is also a good time to get Netbeans set up on it. You can download Netbeans (see instructions on Links page). If you have problems, bring your computer to class to get help from the instructor or lab assistant. You can also stop by WITS to get help.
Instructions for writing your first program:
Buddy System: It is good to find a buddy to collaborate with on this lab. For now, this can just be the person sitting next to you. Introduce yourself to them. You will be writing your own code, but you should feel comfortable consulting with this person if you have questions or problems getting your code to run.
Warning - do not save your work to the C drive of a lab computer for 2 reasons: 1) You can only access this if you are sitting at that exact machine and 2) the lab computers are periodically wiped clean, in which case, you would lose all of your work.
Creating a New Class: Right click on the project name in the Projects tab (left side of window). Select New→Java Class. For the Class Name, enter MyFirstClass and then click the Finish button. A new panel should open. Its tab name should be MyFirstClass.java.
public class MyFirstClass {
}
Add code so that the final program looks like (pay careful attention to the brackets and indentation):
public class MyFirstClass {
public static void main(String[] args) {
System.out.println("Hello Willamette!");
}
}
Save your code but clicking the save button Congratulations, you have just written and run your first program!
What Just Happened? Now, exit Netbeans and navigate to your CS141\Lab1 folder. Look at what folders and files are stored there.
Learning to program is like learning a new language. There is a lot of new vocabulary which you need to learn. Take a look at the vocabulary list on the lectures page. With your buddy, take turns explaining the terms. If you don't understand a term, look it up in your text first. If you are still not clear of the meaning, ask the lab assistant or instructor or someone else in the class.
In the very old days (before you were born!) computers could only display text. Each character on the keyboard was given a 7-bit code representation called it's ASCII code. This was later extended to 8 bits (the Extended ASCII code) so more symbols could be represented. For example, the ASCII code for the letter 'A' is 01000001. If we interpret this as a base 2 number (don't worry if you aren't familiar with base 2), it can be interpreted as the decimal number 65.
The ASCII code is still used as the underlying representation of what we call "text", or "strings" in Java terminology. If you create a document in Notepad, your document is stored exclusively in ASCII. In the above program, we have the print statement:
The characters inside the quotes (Hello Willamette!) is a sequence of ASCII characters called a String.
"ASCII Art" are images that are created using only ASCII characters, for example:
We will look at all of the class's artwork in class!
This lab should not take you very long to do. To reinforce what you have learned, repeat the instructions above for creating a new project and class. Keep repeating until you can do it without looking at the instructions.
This lab will not be graded. However, you are expected to understand and do everything in this lab.
For practice, please submit your code to WISE in order to make sure you understand the submission process which you will need for Lab 2. Here are the steps:
If you have questions, please ask either the instructor or lab assistant for help. Every lab builds on the previous labs. Thus, for the next lab, it will be assumed that you understand all of this.
Don't forget to do the Chapter 1 Reading Quiz on WISE!