Jayesh A Lalwani wrote:
FOr not you can just copy the myapp folder where you want it to go. It should still work
Jayesh A Lalwani wrote:
When you create the project, run the archetype:generate in the folder that you want to generate the project in
Jayesh A Lalwani wrote:
Anyhoo do this: First of all close all your command prompts. Just close them. And open a new one. Then run mvn --version
and java -version in both folders and then post back what you get.
Campbell Ritchie wrote:
As logical and and logical xor and logical or and and andSudhir Srinivasan wrote: . . . How do they operate on booleans? . . .
![]()
Campbell Ritchie wrote:Java Language Specification (JLS) J7 again.
Those bits of the JLS have been surprisingly clear, haven't they!
Campbell Ritchie wrote:
![]()
153 ÷ 8 = 19
153 × 8 = 1224
Only people get confused between ^ used to mean exponentiation and ^ meaning XOR.Look here for a bit more information about superscript numbers...
Campbell Ritchie wrote:...I have failed to find superscript n, however.
Campbell Ritchie wrote:
That link's not javadoc, but the Java Tutorials.
Campbell Ritchie wrote:
They are useful for masks, rapid remainders by powers of 2, particularly when you want to go from hash code to array index (never < 0, never ≥ array.length, so never throws out of bounds exceptions), cyphers, etc. As the link you posted shows, they are less useful to beginners.
Left shift moves the MSB off the number so it is going to vanish anyway, and unsigned right shift is programmed to shift in 0s. Probably done somewhere on the chip. Don't know any more. As far as I know they are all implemented similarly, probably at the level of the chip with NOT, AND, OR, XOR and shift circuits. Don't call left shift signed;......
Campbell Ritchie wrote:
.....it is only right shift that is signed or unsigned. Signed right shift maintains + as + and - as -. Unsigned right shift if both operands are not 0 gives a positive result. Left shift can give + or - depending on whether you get overflow and (if you keep shifting to the left long enough), will give you 0.
Campbell Ritchie wrote:
You will realise that if left shift is like repeated doubling, signed right shift is like repeated halving.
i >> 3 equals i ÷ 2³ with the usual conventions of integer arithmetic.
Campbell Ritchie wrote:You are right about & ^ |. Remember their precedences, and that they are overloaded to operate on booleans, too.
Campbell Ritchie wrote:
Yes, it is a certain number of bits, but you need to go through the Java Language Specification (J7 edition) to find out how many.
Campbell Ritchie wrote:
In the case of … where i and j are both integer primitives, the number of bits shifted is always j & size - 1, where size is the number of bits in i after promotion, 32 for anything other than a long. That means that only the rightmost 5 (6 for a long) bits in j are used to determine the distance to shift. Although you have shown 8‑bit numbers, the shift operations would promote them to ints. If you haven't come across i & j - 1 before, it is a bit like i % j, but j must be an integer obtainable from 2ⁱ, and the result is always ≥ 0. Does that answer your question about negative shifts? They will be converted to 0 or a positive number less than the number of bits in the left operand.
Campbell Ritchie wrote:Try it like this
~0b0000_0001 == 0b1111_1110
… and it becomes a lot clearer.
Winston Gutkowski wrote:
Sudhir Srinivasan wrote:The updated code snippets based on my understanding of your suggestions.
Sudhir,
It's too late for this thread, I suspect, but for future reference: Please DontWriteLongLines.
Richard Tookey wrote:Though I can't see your latest code so I can't be certain....
Sudhir Srinivasan wrote:At the time of building the map object sendMap, by looping thru
the String[] str & adding the key-value pairs to this object,...Richard Tookey wrote:You
just need to normalise each one when using it as a key in the Map! You normalise the String[]
entry when building the Map...
Sudhir Srinivasan wrote:In the GetValues class, when setting the respective field
within the setter method,....Richard Tookey wrote:and you normalise the user's input
when looking up the value in the Map.
Sudhir Srinivasan wrote:In the MapTxtToInt class,
just set (& return) the (normalized) map object sendMap passed from
TestNaturalLanguageMultiply....
......check for String equality of normalized user input with that of the keySet
of the normalized map object.
Richard Tookey wrote:and you normalise the user's input when looking up
the value in the Map.
Richard Tookey wrote:You don't need to modify the String[] containing the alpha representations!
Richard Tookey wrote:You just need to normalise each one when using it as a key in the Map! You normalise the String[]
entry when building the Map
Richard Tookey wrote:
and you normalise the user's input when looking up the value in the Map.
Sudhir Srinivasan wrote:
- attributes inherited from GetValues
- getter method 1:
.. Iteratively, for each String output [output being variable name] in the keySet of tempMap
.. check for String equality of user input 1[access & get superclass method] with output. If true..........
Campbell Ritchie wrote:
Why are you trying................ Don't try to do the whole thing all at once. Do it in bits, and write
methods which test each part before the app is complete.
Richard Tookey wrote:Since you will only ever lookup an integer using the alpha representation of the integer you only need one
Map<String,Integer>. That use as key the normalised alpha representation with hyphens and spaces removed (a simple regex will do this)............
Richard Tookey wrote:Why not just remove all spaces and hyphens from the input supplied by the user and from the keys
when generating the map.......... This way you just have to replace all spaces or hyphens with the empty string; a simple
one line regular expression.
Campbell Ritchie wrote: Start by reducing the main method to its ideal length: 1 statement. Create a class or some classes which will encapsulate your logic. One will have the Map as a field. Create methods to input the two numbers and the operator, and to do the calculation...........