Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

any suggestions

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.awt.*;
public class testBean extends java.lang.Object
{
private int i;
public testBean()
{
}
public void settest(int i1) {
i1 = 3;
this.i = i1;

}
public int gettest() {
return this.i;
}
public static void main(String[] args) {
testBean t = new testBean();
System.out.println(t.gettest());
}
}
The output is 0;
But is think the output should be 3 any suggestions?
 
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is probably not in the correct forum.
You never actually call the settest method.
 
Trailboss
Posts: 23186
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to the Java in General (beginner) forum.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have an empty constructor,I would assume that the "this" which refers to the t object on which the the gettest is called has no initialized value of i.So it takes the value zero.I may be wrong..
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
Try Free Java/.NET Libraries for Word Excel PowerPoint and PDF
htttp://www.e-iceblue.com/free-apis.html
    Bookmark Topic Watch Topic
  • New Topic