Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Introduction
Tasks
Getting Started with Java and the Mac
CS401 Lab1
Huichao Xue
Department of Computer Science
University of Pittsburgh
Sep 8, 2008
Huichao Xue CS401 Lab1
Introduction
Tasks
Outline
1 Introduction
2 Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Huichao Xue CS401 Lab1
Introduction
Tasks
About myself
Contact Information
Huichao Xue
6804 Sennott Square
Department of Computer Science
University of Pittsburgh
Pittsburgh, PA 15260
Personal Homepage: http://www.cs.pitt.edu/~hux10/
Email: hux10@cs.pitt.edu
Office Telephone: +1(412)624-8456
Office Hours
13:30-16:30 on every Friday
Huichao Xue CS401 Lab1
Introduction
Tasks
Directions
This laboratory exercise will introduce you to the CS401
programming environment in the laboratory in 6110 Sennott
Square.
Learn to use Max OSX.
Learn to the Java 2 Software Development Kit (SDK).
Learn to access AFS.
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Outline
1 Introduction
2 Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Log on to AFS
Figure: AFS Login Dialog
Login dialog is shown in figure 1.Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Outline
1 Introduction
2 Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Start a terminal Window
Figure: Terminal Window
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Use Safari to browe the WEB
Figure: UI of Safari
Use Safari to browse to CS401’s webpage, and see the
directions of this lab on http://www.cs.pitt.edu/
~ramirez/cs401/labs/lab1.html.Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Outline
1 Introduction
2 Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Try some commands
Use “pwd” to display the path to your current directory.
Use “man” to browse manuals.
Use “cd” to change your current directory. Type
cd /afs/pitt.edu/home///
Use “mkdir” to make new directories. use this make create
“private/cs401” in your home directories.
Other commands: date, cp, mv, rm . . .
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Outline
1 Introduction
2 Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
pico’s screenshot
Figure: pico
Shown in figure 4 is what pico looks like.
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Use pico to input a Java program
The Java program
/ / CS 0401 Lab1
/ / P rac t i ce Java program wi th a dual purpose :
/ / 1) To f am i l i a r i z e you wi th the pico ed i t o r
/ / 2) To f am i l i a r i z e you wi th Java syntax
public class Lab1
{
public s ta t i c void main ( S t r i n g [ ] args )
{
i n t t o t a l = 87 , number = 10;
double doubleAve ;
i n t i n tAve ;
doubleAve = ( ( double ) t o t a l ) / number ; / / f l o a t i n g po in t d i v i s i o n
i n tAve = t o t a l / number ; / / i n t ege r d i v i s i o n
System . out . p r i n t l n ( " The double average i s " + doubleAve ) ;
System . out . p r i n t l n ( " The i n t e g e r average i s " + in tAve ) ;
i n t value1 = 3 + 4 ∗ 5; / / d e f au l t precedence
i n t value2 = (3 + 4) ∗ 5; / / change precedence wi th parens
System . out . p r i n t l n ( " Value1 i s " + value1 ) ;
System . out . p r i n t l n ( " Value2 i s " + value2 ) ;
}
}
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Outline
1 Introduction
2 Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Huichao Xue CS401 Lab1
Introduction
Tasks
Logging in
Begin to use Mac OSX
Try some basic commands
Use “pico” to edit files
Compile and run a Java Program
Use the commands “java” and “javac”
Using two steps to run a program
javac ex1.java
java ex1
Show the version of Java
java -version
Huichao Xue CS401 Lab1