lecture06

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
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 Right Arrow Icon
Ask a homework question - tutors are online