Matthew Melendez

Members
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

100 Neutral

About Matthew Melendez

  • Rank
    Newbie
  1. Java Class Constructor Question

    [quote name='IceBreaker23' timestamp='1328216179' post='4908836'] There won´t be an error. Although it´s not a good programming style. The better way is to call the constructor of the image in your own constructor like this: [CODE] package foo; import java.awt.Image.*; import java.awt.image.BufferedImage; public class foo { BufferedImage image; public foo() { image = new BufferedImage(64,32,BufferedImage.TYPE_INT_ARGB) } public void setRgb(int x, int y, int rgb) { image.setRGB(x,y,rgb); } } [/CODE] Hope I could help you! [/quote] I tired that and the setRgb() method can't find the image object. I think it might be out of scope of the setRgb() method.
  2. Can anyone find any problems that make arise with this code? Will there be a problem with an empty constructor like this? [code]package foo; import java.awt.Image.*; import java.awt.image.BufferedImage; public class foo { BufferedImage image = new BufferedImage(64,32,BufferedImage.TYPE_INT_ARGB); public foo() { //no code here } public void setRgb(int x, int y, int rgb) { image.setRGB(x,y,rgb); } } [/code] I want to be able to create a new foo object like so: [code] foo object = new foo(); [/code] and be able to do this: [code] object.setRgb(5,5,0x00000000) [/code]