Java word count program

The ideas is to split the string into words on any whitespace character occurring any number of times. The split function of the String class returns an array containing the words as its elements. Printing the length of the array would yield the number of words in the string.

CreateProcess error=2, The system cannot find the file specified

Assuming that winrar.exe is in the PATH, then Runtime.exec is capable of finding it, if it is not, you will need to supply the fully qualified path to it, for example, assuming winrar.exe is installed in C:/Program Files/WinRAR you would need to use something like… Personally, I would recommend that you use ProcessBuilder as it has some additional configuration abilities amongst other things. Where possible, you … Read more

Java: how to initialize String[]?

You need to initialize errorSoon, as indicated by the error message, you have only declared it. You need to initialize the array so it can allocate the correct memory storage for the String elements before you can start setting the index. If you only declare the array (as you did) there is no memory allocated for the String elements, but only a reference handle to errorSoon, and will … Read more

Simulating Game of Craps in JAVA

This condition is always true, so you have an infinite loop. Also, why do you pass d1 and d2 into the roll() function? They are completely unused and unneeded.

koch snowflake java recursion

You will have to paint the same curve in each of the three directions of a triangle. You can do this by writing a function drawKochCurve(double level, double sideLength, double additionalAngle) and calling it three times, adding the additionalAngle. Wikipedia has more details: The Koch curve originally described by Koch is constructed with only one … Read more

What does this expression language ${pageContext.request.contextPath} exactly do in JSP EL?

The pageContext is an implicit object available in JSPs. The EL documentation says The context for the JSP page. Provides access to various objects including:servletContext: …session: …request: …response: … Thus this expression will get the current HttpServletRequest object and get the context path for the current request and append /JSPAddress.jsp to it to create a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)