Skip to main content

CS101: Introduction to Computer Science I

Page path
  • Home /
  • Courses /
  • Course Catalog /
  • Computer Science /
  • CS101: Introduction to Computer Science I /
  • Unit 5: Control Structures /
  • 5.3: The 'switch' Statement
Back to 'Unit 5: Control Structures'
  • 5.3: The 'switch' Statement

    • Central Connecticut State University: Bradley Kjell's "Introduction to Computer Science Using Java, Chapter 43: More Ways to Make Decisions"

      Please read the chapter. This chapter discusses switch statement and '?' operator to write conditional statement.

      As you read this tutorial, you will learn that sometimes it is better to use a 'switch' statement when there are multiple choices to choose from. Under such conditions, an if/else structure can become very long and at times difficult to comprehend. Please read the section under the heading "Many-way Branches," and pay special attention to the syntax of the 'switch' statement.

      Once you have read the entire tutorial, you will understand the similarity of the logic used for the 'if/else' statement and 'switch' statement and how they can be used alternately.

    •  Quiz on the Conditional Operator and the Switch Statement

      Attempt this ungraded quiz.

Navigation

Art History
Biology
Business Administration
Chemistry
Communication
Economics
English
History
Mathematics

Creative Commons License
© Saylor Academy 2010-2018 except as otherwise noted. Excluding course final exams, content authored by Saylor Academy is available under a Creative Commons Attribution 3.0 Unported license. Third-party materials are the copyright of their respective owners and shared under various licenses. See www.saylor.org/open/licensinginformation for detailed licensing information.

Saylor Academy and Saylor.org® are trade names of the Constitution Foundation, a 501(c)(3) organization through which our educational activities are conducted.

Terms of Use | Privacy Policy