福建农林大学计算机与信息学院JAVA语言程序设计课件Chapter2 Primitive Data Types and Operations.pptVIP

  • 1
  • 0
  • 约1.85万字
  • 约 49页
  • 2019-05-06 发布于广东
  • 举报

福建农林大学计算机与信息学院JAVA语言程序设计课件Chapter2 Primitive Data Types and Operations.ppt

* Introduction to Java Programming Chapter 2 - * 2.15 The String Type The char type only represents one character. To represent a string of characters, use the data type called String. For example, ? String message = Welcome to Java; ? String is actually a predefined class in the Java library just like the System class and JOptionPane class. The String type is not a primitive type. It is known as a reference type. Any Java class can be used as a reference type for a variable. Reference data types will be thoroughly discussed in Chapter 6, “Classes and Objects.” For the time being, you just need to know how to declare a String variable, how to assign a string to the variable, and how to concatenate strings. * Introduction to Java Programming Chapter 2 - * String Concatenation // Three strings are concatenated String message = Welcome + to + Java; ? // String Chapter is concatenated with number 2 String s = Chapter + 2; // s becomes Chapter2 ? // String Supplement is concatenated with character B String s1 = Supplement + B; // s becomes SupplementB * Introduction to Java Programming Chapter 2 - * 2.16 Programming Style and Documentation Appropriate Comments Naming Conventions Proper Indentation and Spacing Lines Block Styles * Introduction to Java Programming Chapter 2 - * Appropriate Comments Include a summary at the beginning of the program to explain what the program does, its key features, its supporting data structures, and any unique techniques it uses. Include your name, class section, instructor, date, and a brief description at the beginning of the program. * Introduction to Java Programming Chapter 2 - * Naming Conventions Choose meaningful and descriptive names. Variables and method names: Use lowercase. If the name consists of several words, concatenate all in one, use lowercase for the first word, and capitalize the first letter of each subsequent word in the name. For example, the variables radius and area, and the method computeArea. * Intro

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档