Browsing 7239 questions and answers with Jon Skeet
This is the problem: public static void choice() { int user_choice = 0; ///This is the method giving me grief!!!!!! user_choice = Input.getInt("Enter 1 if you want to change English to Morse code, and enter 2 to change Morse code... more 3/28/2014 9:41:06 PM
You don't nullify an object - you change a variable's value to null. It's really, really important that you understand the difference between objects, variables and references. That's rarely useful, but it would be extremely odd to lead... more 3/28/2014 7:35:26 PM
Basically you need to round up the number of bytes needed in your first method: byte[] ret = new byte[(bits.Length + 7) / 8]; bits.CopyTo(ret, 0); Your second method already looks okay at first glance... it certainly fills the right... more 3/28/2014 5:52:30 PM
Well, you need temporary storage of some description. If you have enough memory, you could do this in one go: int[] buffer = new int[placesToShift]; // Save the start of the array in the buffer System.arraycopy(array, 0, buffer, 0,... more 3/28/2014 5:25:20 PM
Rather than using string concatenation, use Path.Combine. Aside from anything else, that will be portable if you ever want to use Mono, too. Oh, and there are simpler ways to create a text file too: using (var writer =... more 3/28/2014 3:59:11 PM
Currently you're trying to use the raw mapper type, which erases all kinds of things. As soon as you start using the generic type, all is fine - and type inference can help you: new Mapper<>(TestEvent::setId); Adding <> is... more 3/28/2014 3:43:35 PM
Don't convert it to a string at all where you don't need to. Convert from the string you get from the user using DateTime.ParseExact, and then keep it as a DateTime. Use that as a parameter in parameterized SQL to insert it into the... more 3/28/2014 3:12:19 PM
Well, it sounds like it would be a good idea to separate this into more appropriate types: LocalTime userTime = ...; // Parse the user input DateTime now = DateTime().now(); LocalDate today = now.toLocalDate(); LocalDate resultDate =... more 3/28/2014 2:46:41 PM
You should call readLine() once and use that input - otherwise you're checking a different line each time! String line = input.readLine(); // readLine returns null for "end of input" if (line == null || line.isEmpty()) { // Report... more 3/28/2014 2:25:00 PM
Yes - it's useful to make it clear that you're interested in bitshifting operations; that you're thinking of a value as "a sequence of bits" rather than a magnitude. For example, if I'm trying to represent a 32-bit integer in four bytes... more 3/28/2014 2:23:04 PM