Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Default Call a String from a Java class to another class without creating an instance

    Hi All,

    Need your help. I want to call a String from a java class to another java class without creating an instance.

    Current Example:
    public class DomainAndPageTitles {

    /*Collection of all Web links used in all Environment*/


    public String TestURL = "http://test-website.me";
    public String TestSignInURL = TestURL + "/SignIn.aspx";

    public String HomePageTitle = "Cheap deals with us";
    public String SignInPageTitle = "HOTELS & APARTMENTS Bookings and Reservations";

    }


    public class searchPanelTest {

    public DomainAndPageTitles Domain = new DomainAndPageTitles();
    private WebDriver driver;

    public void setupBeforeTest() {

    //Loading test website using selected browsers
    driver = Driver.get(Domain.TestURL);

    }

    }

    As you can see in searchPanelTest class I am creating an instance to call a String from DomainAndPageTitles class, however I want to call a String without creating an instance. Please see below.

    public class searchPanelTest {

    private WebDriver driver;

    @Before
    public void setupBeforeTest() {

    //Loading test website using selected browsers
    driver = Driver.get(DomainAndPageTitles.TestURL);

    }

    }

    Appreciate your help.

    Best Regards,
    Kam

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default Re: Call a String from a Java class to another class without creating an instance

    Make them static final constants.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Default Re: Call a String from a Java class to another class without creating an instance

    Appreciate your quick response. You have solved my problem.

Similar Threads

  1. Adding the Class instance name to an output string
    By wfsteadman in forum New To Java
    Replies: 3
    Last Post: 01-19-2013, 04:19 PM
  2. Replies: 1
    Last Post: 04-21-2012, 06:03 PM
  3. Finding and Creating Instance of Every Class in Package
    By Julian Trust in forum New To Java
    Replies: 5
    Last Post: 06-25-2011, 08:34 AM
  4. Help with creating an instance of a class extension
    By Inferno719 in forum New To Java
    Replies: 19
    Last Post: 05-04-2011, 03:53 AM
  5. Replies: 0
    Last Post: 03-27-2011, 05:49 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •