Topic
  • 1 reply
  • Latest Post - ‏2014-08-12T17:21:47Z by dweditor
dweditor
dweditor
8 Posts

Pinned topic PBCK Editor test

‏2014-08-12T17:05:26Z |
import java.awt.Rectangle;

public class ObjectVarsAsParameters
{    public static void main(String[] args)
        {     go();
        }
        
        public static void go()
        {     Rectangle r1 = new Rectangle(0,0,5,5);
                System.out.println("In method go. r1 " + r1 + "\n");
                // could have been 
                //System.out.prinltn("r1" + r1.toString());
                r1.setSize(10, 15);
                System.out.println("In method go. r1 " + r1 + "\n");
                alterPointee(r1);
                System.out.println("In method go. r1 " + r1 + "\n");
                
                alterPointer(r1);
                System.out.println("In method go. r1 " + r1 + "\n");
        }
        
        public static void alterPointee(Rectangle r)
        {     System.out.println("In method alterPointee. r " + r + "\n");
                r.setSize(20, 30);
                System.out.println("In method alterPointee. r " + r + "\n");
        }
        
        public static void alterPointer(Rectangle r)
        {     System.out.println("In method alterPointer. r " + r + "\n");
                r = new Rectangle(5, 10, 30, 35);
                System.out.println("In method alterPointer. r " + r + "\n");
        }
        
        
}

 

  • dweditor
    dweditor
    8 Posts

    Re: PBCK Editor test

    ‏2014-08-12T17:21:47Z  
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.Scanner;
    
    
    public class URLExpSimple {
    
        
        public static void main(String[] args) {
            try {
                URL mySite = new URL("http://www.cs.utexas.edu/~scottm");
                URLConnection yc = mySite.openConnection();
                Scanner in = new Scanner(new InputStreamReader(yc.getInputStream()));
                int count = 0;
                while (in.hasNext()) {
                    System.out.println(in.next());
                    count++;
                }
                System.out.println("Number of tokens: " + count);
                in.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

     

    Attachments