Class Note for CS 357 at UA-Data Structures (5)
Class Note for CS 357 at UA-Data Structures (5)
Popular in Course
Popular in Department
This 5 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Alabama - Tuscaloosa taught by a professor in Fall. Since its upload, it has received 14 views.
Reviews for Class Note for CS 357 at UA-Data Structures (5)
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
CS 357 Data Structures Class 03 January 14 2001 Announcements Finish chapter 1 forWednesday sections 14 18 19 and 110 couldn t hurt but are not required for Wednesday No class on Monday January 21 in observance of Martin Luther King Jr s birthday Discussion group to be up this afternoon Homework due in class on Friday mime 357C135 mm p Basics Primitives boolean true or false char 16bit Unicode character byte 8bit signed two s complement integer short 16bit signed two s complement integer int 32bit signed two s complement integer long 64bit signed two s complement integer oat 32bit oatingpointnumber double 64bit oating point number Two s complement See http mmwdukeedutMcps104woscompmmr mime 357C135 mm p Basics Literals Any constant value that can be used in an assignment or other expression Boolean true and false Integer 38 46 32 32bit by default Lung BEL ABL VBZL Double 31415 6 322 64bit by default Fluat 3 MlEF BSZZf Expunentlals alluvved 3 MEI ma MEZf Strings Typically multiple characters in double quotes uulck brawn fux Object null object reference m m c 357 Class Ms Basics Literals cont Character typically single character in single quotes l l by C Special nEWllnE b backspace v furmfeed 7 ll duuble uuute m m c 357 Class Ms Basics Operators Assignment Arithmetic Binary 39 Arithmetic Unary gtgtampamp Logical Binary Logical Unary 39 ampquotltltgtgtgtgtgt Bitwise Binary Bitwise Unary String concatenation m m c 357 Class Ms Quick Quiz Give the values of each of the following variables after these statements execute int Int ri2 m m c 357 Class mm Basics Operators cont Operational Assignment ltvariabegt ltopgt egg Y Y Y According to the book evaluates to ltvariablegt ltvariablegt ltopgt ltexpressiongt Try this int i i 3 i 2 3 Systemoutprintlni Actually evaluates to ltvariablegt ltvariablegt ltopgt ltexpressiongt mm c 35mm Ms ltexpressiongt Basics Casting Ordinary lttypegtltvariabegt Floating point number cast to a non oating point number is atruncation i e the precision is lost not rounded double d Z 4 5 mama lZ4 With Operators double dl dZ dB mt llZ 2 m uuuniew dDublElZ Naplmitcastufparamaers d2 Z ll l2 lmpllclt cast El double fur assignment d3 Z M d2 mn5 u2nniuann m m c 357 Class mm Basics Casting cont ImpIICIt int lrEsult l3 duuble dresult dZS Z dresultZid Curnputes dresult El 9375 iresultZid n Dues nut curnpile Gives a pussible luss ur precisiun errur Needs an explicit cast Elf either u ur the result Elf id V floaty45 IIAlso gives an error Why lmplicitJExplicit with String Objects Cannot explicitly cast Stringt String5 Must do something like String s 34 String y lnteger msmnmaai String 2 s z y mmc 357cbssumas r em Number Objects Byte Integer Integer n n newlnteger35 Float Short Long Double FJIEIICSSMChsstas p e Basics Arrays lttypegt ltnamegt ltval0gtltval1gtltvaIN1gt Numbered 0N l N obtained with length If no initialization must use new operator new operator allocates space amp creates objects mime 357C135 Ms p e12 Quick Quiz Describe what happens when each of Code Blocks the code blocks to the right are 1 int gtlt 112131411 inserted into the code below 1 Will 01 gtltE3 class foo int gtlt new int Ell public static void main gtltE39 u insert block here Systemoutprintln x0 4 M X gtlt 1 12131411 5 int X X new int 41 X 1 12131411 FJIEIIC 357Cbsstes p 13 Arrays cont public class ArrayOfArraysDemo public static Void malnlstnng args quotJetsons39 quotDaphnequot roriinti o I lt cartoonsJength mu systemoutpnnticartoonsmio39 for lint 1 lt camonslilength 14 systemomprinticartoonsmm quot quoti systemoutpnntinii mime 357C135 Ms p ti Quick Quiz 1 Rewrite each of the following to achieve the intended result a String s49 39 b String t Pi String 31415 c String u22 2 What is the result ofthe following code What changes must be made to have the intended result public static void Link Node rciment Node fNext Node k new NodefCurrentdatanull rcime k knext fNext mime 357C135 Ms p e15
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'