hi guys j

is there a way on how to analyze java snippet of codes, like for loops, while loop to check to see what will be the result of it, whether it would run, what results, or if it would give you any kind of syntax error, run time error or logical error,
do you have that facility on this site available.

heard of Unit testing?

no davaearmour
first time of hearing about it thanks a lot

Unit testing is a means to test the "smallest units" (methods) in your code. You either provide all the parameters, or you create mocks for services required by your method (if you search for this, it returns result A, if you search for that, it returns result B, if you search for yet something else, it 'll throw an exception, ...)

JUnit

Here are a few links sure worth reading through:
http://stackoverflow.com/questions/3258733/new-to-unit-testing-how-to-write-great-tests
https://developer.salesforce.com/page/How_to_Write_Good_Unit_Tests

you can write tests that cover your entire code, meaning you'll be able to test every possible scenario of the application before it's even used, and thus prevent any mistakes.

thnz stultuske again

At a far far simpler level I have a NetBeans project that looks a bit like

   class test {
      public static void main(String[] args) {
         // put code to test here
      }
    }

so when some interesting bit of code appears on DaniWeb I can just paste it in there and compile/run/debug it with roughly zero effort.

I have a similar one that creates and dsiplays an empty JFrame, so I can check out Swing code quickly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.