包含标签 Java 的文章

【CS61B】LEC2 Defining and Using Classes

1 Static vs Non-Static Methods 1.1 Static Methods Java中的所有代码都必须是类class中的一部分,大多数代码在方法methods中: public class Dog { public static void makeNoise() { System.out.println("Bark!"); } } 如果运行 Dog 类,将会报错: $ java Dog Error: Main method not found in class Dog, please define the main method as: public static void main(String[] args) 为了执行Dog类,我们需要添加一个main方法。或者,我们也可以单独创建一个 DogLauncher 类来执行……

阅读全文

【CS61B】LEC1 Intro, Hello World

从今天开始,将follow数据结构的一门经典课程,UC Berkeley的CS61B。 1 Hello World Let’s look at our first Java program. When run, the program below prints “Hello world!” to the screen. public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world!"); } } For those of you coming from a language like Python, this probably seems needlessly verbose. However, it’s all for good reason, which we’ll come to understand over the next couple of weeks. Some key syntactic features to notice: The program consists of a class declaration, which is declared using the keywords public class. In Java, all code lives inside of classes. The code……

阅读全文

【CS61B】利用Github管理课程代码并搭建Auto Grade环境

学习CS61B的一个挑战便是需要学习使用Git and github。由于非伯克利注册的学生不能够得到instructional number,因此我们需要在自己的github上创建一个专有的repository,我将自己的命名为cs61b-sp18,有了这个repo,我们就可以把本地的课程代码/作业代码/项目代码推送到这个远程库中,然后上传到autograder进行评分。

……

阅读全文