Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Forgetting about constructors  RSS feed

 
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?
 
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");
}

}
 
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.
 
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!