lecture06

# lecture06 - Class 6: Lab Session on Class Classes and...

This preview shows pages 1–6. Sign up to view the full content.

Class 6: Lab Session on Classes and Objects Class 6: Lab Session on Classes and Objects 1.00/1.001 - Introduction to Computation and Problem Solving Using Methods Methods are invoked using the dot (.) operator Method always ends with parentheses BigInteger a= new BigInteger(“1000000000000”); BigInteger z= new BigInteger(“23”); BigInteger c= a.add(z); // c= a + z If (z.isProbablePrime(15)) // is z prime? System.out.println(“z is probably prime”); Public data fields are also invoked with the dot operator. No parentheses after field name int j= a.somePublicField; // Example only 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Objects and Names a= BigInteger a= new BigInteger(“1000000000000”); BigInteger 1000000000000 Objects and Names a= r= Random BigInteger a= new BigInteger(“1000000000000”); Random r= new Random(); BigInteger 1000000000000 2
Objects and Names Random r= new Random(); a= r= Random b= ) BigInteger a= new BigInteger(“1000000000000”); BigInteger b= new BigInteger(32, r); BigInteger 1000000000000 BigInteger (32, r 1734530390 Objects and Names Random r= new Random(); a= r= Random b= c= ) BigInteger a= new BigInteger(“1000000000000”); BigInteger b= new BigInteger(32, r); BigInteger c; BigInteger 1000000000000 BigInteger (32, r 1734530390 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Objects and Names Random r= new Random(); c= b.add(a); a= r= Random b= c= ) BigInteger a= new BigInteger(“1000000000000”); BigInteger b= new BigInteger(32, r); BigInteger c; BigInteger 1000000000000 BigInteger BigInteger (32, r 1734530390 1001734530390 Objects and Names Random r= new Random(); c= b.add(a); a= r= Random b= c= ) g= BigInteger a= new BigInteger(“1000000000000”); BigInteger b= new BigInteger(32, r); BigInteger c; BigInteger g= a; BigInteger 1000000000000 BigInteger BigInteger (32, r 1734530390 1001734530390 4
Using the BigInteger Class import java.math.*; // For BigInteger import java.util.*; // For Random public class BigIntTest { public static void main(String[] args) { BigInteger a= new BigInteger("1000000000000"); Random r= new Random(); // Random nbr generator BigInteger b= new BigInteger(32, r); // Random

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/29/2011 for the course CIVIL 1.00 taught by Professor Georgekocur during the Spring '05 term at MIT.

### Page1 / 12

lecture06 - Class 6: Lab Session on Class Classes and...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online