Weekly Notes (20 and 22 October)
Weekly Notes (20 and 22 October) CSE 1310 - 003
Popular in INTRODUCTION TO COMPUTERS & PROGRAMMING
Popular in ComputerScienence
This 4 page Class Notes was uploaded by ASD Notetaker on Sunday October 25, 2015. The Class Notes belongs to CSE 1310 - 003 at University of Texas at Arlington taught by Janice Carter M Tiernan in Fall 2015. Since its upload, it has received 24 views. For similar materials see INTRODUCTION TO COMPUTERS & PROGRAMMING in ComputerScienence at University of Texas at Arlington.
Reviews for Weekly Notes (20 and 22 October)
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: 10/25/15
Weekly Notes 20 and 22 October 0 useDelimiter The useDelimiter method expects an argument of type String that specifies a regular expression for recognizing delimiters 0 findinline This method attempts to find the next occurrence of a pattern constructed from the specified string ignoring delimiters 0 Getting input from a file We need to use a new import statement importj avaioFile to take the input from the file We will need one more import statement for file not found exception import javaioFileNotFoundException We will also need to use try and catch statements File tempDate newFile DateTemptxtquot try Scanner input newScanner tempDate catch FileNotFoundException fnf Do something else 0 An array is a container object that holds a fixed number of values of a single type The length of an array is established when thearray is created After creation its length is fixed 0 Declaring Arrays The most simple method is double values new doublelO The array named values can store 10 double values values154 This assigns 54 as the second value in the array Remember Array goes from 0 to n1 here n10 ldUIE UELIdWIHg Hf39f39dVb int j numbers new 139 nt 1 An area ef ten integera Pill eletttenta are initialized with aere nal int LENGTH 1D It is a geed itiea te use a tiaittedi eeuataut int numbers new intLENGT H instead eta Inagieututtber int length inneatlntvt Theleugthueeduet beaeeitatattt deuble data new duub1elength int equanee t I 1 4 9 16 An aurar ef ve integers with initial V itl Steingi friends Emily Heb Kinda Attartayeftltreeatriuga d ubie data new intl Erma Yea eaiiiiet initialiaea dinublef r variable with an array ef type int j 0 You can also specify the initial values when declaring the array double values 32 54 675 29 35 80 115 445 100 65 0 When you copy an array variable into another both variables refer to the same array For example int scores 10 9 7 4 5 int values scores Copying array reference You can modify the array through either of the variables scores3 10 systemoutprintlnvalues3 Prints 10 0 Filling an array it can be easily done by using for loop for int i O i lt valueslength i valuesi i i 0 Instead of using for loop to separate elements in an array during output like this for int i O i lt valueslength i if i gt O systemoutprintquot quot systemoutprintvaluesi We can use ArraystoString method For example ArraystoStringvalues returns a string describing the contents of the array values in the form 32 54 675 29 35 Copying an array Array variables do not themselves hold array elements They hold a reference to the actual array If you copy the reference you get another reference to the same array double values new double6 Fill array double prices values refer figure 1 here just a reference is made To actually copy an array or to make a true copy of an array call the ArrayscopyOf method For calling ArraycopyOf you will need to import import javautilArrays double prices ArrayscopyOfvalues valueslength refer figure 2 The call ArrayscopyOfvalues n allocates an array of length 11 copies the first 11 elements of values or the entire values array if n gt valueslength into it and returns the new array H r a 2 w n
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'