• Post Reply Bookmark Topic Watch Topic
  • New Topic

Forgetting about constructors  RSS feed

 
Jacob Steingart
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been picking up Java again after a long time with no computer, and I can't remember how to make your own constructor, more specifically how to pass parameters and use them from one class to another. can someone help me?
 
Rogerio Kioshi
Ranch Hand
Posts: 690
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Test{
public Test(String param1){
//Some code here...
}

}

public class TestTest{
public static void main(String args[]){
Test t=new Test("A test");
}

}
 
Stuart Smith
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rogerio Kioshi:


Edited for clarity hope you do not mind
 
Jacob Steingart
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yay! Thanks to you guys, my constructors are working flawlessly.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Jacob Stein****",
Please check your private messages.
-Ben
 
Stuart Smith
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jacob Stein****:
Yay! Thanks to you guys, my constructors are working flawlessly.



Your welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!