The test object is created on the outside of the main method 10

Updated on technology 2024-04-08
11 answers
  1. Anonymous users2024-02-07

    The upstairs one is also a solution, but there is another solution, which you can write in the main method:

    test3 test = new test3();

    The reason is the same: the static method cannot directly call the non-static method, it must be called again by a new object, and the static method can be called directly in the non-static method, because the static method belongs to the class, not to a certain instance object, so first, you either add the static modifier in front of the attribute t of the test3 class, or in the main method, a new test3 instance object, This allows you to call the non-static member of test3 in the main method!

  2. Anonymous users2024-02-06

    ;Reported 2 errors

    You know, there are two things in a class, one is a property and the other is a method, and the main method is the method t t = new t();

    It's the property but you're wrong here, so it will; Error.

    There are two things wrong. 1.to static t t = new t(); Since the main function is static, any other method or property used must also be declared static.

    2.After changing it, it will still report an error, because your; Written incorrectly, instead;

  3. Anonymous users2024-02-05

    public class fortest;

    fortest ft=new fortest();new a current method.

    Call the method below.

    public void a(int arr);}

  4. Anonymous users2024-02-04

    Unit tests can be done with junit, and there's no need to create a main method per class.

  5. Anonymous users2024-02-03

    Each class creates a main method to run each method of the class, novices can use this method for unit testing, and later can use junit for unit testing, one method to test one method, both can be, depending on which one you prefer.

  6. Anonymous users2024-02-02

    In this case, each class can be run separately, and only the main method can be run!! You can also use Junit for unit testing, which is more convenient and flexible.

  7. Anonymous users2024-02-01

    1 Introduce the class bimport in package2 in package1;

    class a

    2. Create with the full package name and class name.

    class a}

  8. Anonymous users2024-01-31

    import package2.*;Import all the classes in package2.

    class a}

  9. Anonymous users2024-01-30

    You can configure Junit to test modules and test only a certain function (for example, an operation in a DAO).

  10. Anonymous users2024-01-29

    You write an output print statement in the main method and the normal thread method, which is printed first, which takes precedence.

  11. Anonymous users2024-01-28

    You can write a test class to test. In fact, the main method can also be written.

Related questions
10 answers2024-04-08

I don't understand your intentions, so you probably want to use polymorphism. >>>More

11 answers2024-04-08

Pass unit tests.

and integration testing, which can only guarantee the implementation of the functions of software development. However, it is not possible to confirm whether it meets the needs of users in actual operation, and whether there is a large number of hidden dangers that will induce errors under actual use conditions. For this reason, the developed software must undergo standardized system testing. >>>More

12 answers2024-04-08

If ifix has been restored before,The original project will be automatically opened when it runs.,In this case, you can close the original project first.,Then click to create a new one.。。

21 answers2024-04-08

Think more about the way of thinking of the opposite sex. There are many results of the difference in the way of thinking of men and women, and it can also be observed and learned in real life. This can make your communication with the opposite sex smoother, and increase the number of people of the opposite sex around you to a certain extent.

7 answers2024-04-08

"Is testing and QA the same? ”

Of course not! ” >>>More