~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

if your program has no I/O, and there's nothing else running on the machine at the same time, then for most purposes you can assume CPU time == real time

If the program in multi-threaded, the CPU time gives the "total" time spent by each CPU/core. So even if the real/wall time is 1s, it's quite possible that the CPU time might be 4s for a multi-threaded CPU intensive code.

@corol
There are two techniques which you can put to use:

  1. Use the JMX API to get an approximate CPU time for all threads
  2. Use the time unix command when executing your Java process

For (1), you can have a look at the Thread MBean. Here is a small snippet:

public class TestIt {

    public static void main(String[] args) throws Exception {
        int numThreads = 5;
        long start = System.currentTimeMillis();
        for (int i = 0; i < numThreads; ++i) {
            new MyThread().start();
        }
        ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
        long[] allThreadIds = threadMXBean.getAllThreadIds();
        System.out.println("Total JVM Thread count: " + allThreadIds.length);
        long nano = 0;
        for (long id : allThreadIds) {
            nano += threadMXBean.getThreadCpuTime(id);
        }
        System.out.printf("Total cpu time: %s ms; real time: %s", nano / 1E6, (System.currentTimeMillis() - start));
    }

}

class MyThread extends Thread {

    public void run() {
        int sum = 0;
        for (int i = 0; i < 1000000; ++i) {
            sum += i;
        }
        sum = sum + 1;
    }

}

Of course, this snippet has problems of its own. This code won't consider …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

since you here are explicitly saying you want a new Object, a new String will be created in the pool, and your second variable will point to that one

This isn't correct AFAIK; instantiating new strings on demand doesn't send them to the "string pool" unless the newly created string is specifically/explicitly interned.

and right now I can't think of a single reason why you would want to do that

Creating a new String isn't a common occurrence though it might be required in some cases. Two reasons I can think of:

  • You are working with a mixed-mode binary protocol which has binary content interleaved with textual content. If you want to create a String out of bytes, you need to use the string constructor
  • You are reading large amounts of textual data from an external source (each line containing around 1K-10K words) but you need to work with just a small chunk of that text. The substring method returns a shallow copy of the string so the substring always refers to the char array of the original string. This is a problem because if you are doing substring on a very large string, you'll end up hanging around with more data than you require. In this case, creating a new String is a good way of making sure the large string is eligible for garbage collection.

As an example for the above explanation:

public class Testi {

    public static void main(String[] args) throws Exception …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

BTW, on the Python feud, people respond differently to a new language like python. Personally, I think I got put off from python by the drastically different syntax, but mostly by the lack of clarity in type specifications, scoping rules, abstract memory model, etc.

I don't think kids or those starting out with programming need to worry about such things. Nothing is more unrewarding than sitting down to solve a problem only to find the language getting in the way, time and time again. Is C++ or C a bad choice? Absolutely no. Is it a bad first language? If you are trying to learn programming, yes, I would say so.

and those who see those things as annoying things to worry about in C++ it is not surprising they adopt Python very easily, but those who see these things as great tools to create robust software will have a hard time letting go of it

I can sense this going in the direction of "this is what separates the boy's from the men". Python is pretty much capable of creating a "robust" software. Heck, I have seen Python being used as a backbone for creating pricing related apps in a "big bank".

Those of us who have tried to teach programming to kids would be pretty much aware of the problems one faces when using a language like C or C++ as the first language. I know I have. I'd personally recommend the top to …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Any specific reason you want to load resource relative to a class and not relative to a classloader using MyClass.class.getClassLoader().getResourceAsStream("my/pkg/file.txt") ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Such a feature already exists; look for a "message like image" next to the feed icon at the top of your post.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This is not an issue but a concious site-wide decision. IIRC, this was put in place to ensure we don't end up getting members who post for the sole purpose of "exposing" their sig links to "teh internet". As a user, you have no control over this behaviour, so no, it can't be resolved.

Similar thread in the past.

happygeek commented: absolutely +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Please don't conflate strong disagreement and resetment towards advice given with impoliteness.

Plus, my first post was meant to push OP to do a bit more research about BigIntegers and you pretty much handed the answer. Questions posted (especially by studnents) are much more about the learning involved in reaching the answer rather than "getting" the answer.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

So? It still doesn't change the fact that it will fail for certain inputs as mentioned above and the worst thing is that regular tests which don't exercise the limits won't be able to uncover this problem.

Please don't provide sub-standard advice to beginners who wouldn't know the difference between "working" and "correct" code. It's a pity that my post, which tried to push adil in the right direction was downvoted. If someone wants to challenge my post above, I would be more than happy to provide reasons/discuss.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Convert it to long first using Long.parseLong() and then convert the long to BigInteger using BigInteger.valueOf(long val)

This won't work if the string representation is outside the "long" data type range, which is one of the main motivation for using BigInteger...

thanks dear it worked, but isn't there any direct way for such a conversion??

There is no direct way to do these conversions given that like C++, Java doesn't support operator overloading.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

In what way is the BigInteger constructor which accepts a string not working out for you?

Philippe.Lahaie commented: the constructor that receives a char array was definitly the right answer all along ;) +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try wrapping the `value` elements in a parent element called `values` and have a look at this thread.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The difference is that with SSS, you are providing a padding for the millisecond field. So if the milliseconds elapsed are 9, it'll be shown as "009". If you instead had just "S", it would be shown as "9". Regarding the 'E' format specifier, you can simply replace the 3 E's with a single E without any visible change in the output. If you have more than or equal to 4 E's, it'll use the full form of the day of the week. For e.g. with a single E, the output would be 'Fri' but with 4 E's it would be 'Friday'.

Also, the locale for a date formatter is by default the default locale so you can drop the second argument to the SimpleDateFormat constructor.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The format `dd/MM/yyyy - HH:mm:ss.S E` should do the trick. For future references, look into the Javadoc of the SimpleDateFormat class.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It still displays the old one!? Whyy??

Apart from answering the questions posed above, make sure that you do a clean build and then run the application. It's quite possible that the old image still resides in the build directory of Netbeans. Also, check where exactly is this application run from (search for the dir Netbeans uses) and verify it has the same image in consideration.

peter_budo commented: +1 for clean build +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Sorry, but I still didn't get it.

Fair enough. To understand the need for a solution, you need to first have a good grasp on the problem you are trying to solve. So my question to you is: what would be your solution if you are asked to come up with a way to ensure that clients are forced to implement a subset of methods found in an interface? E.g.

interface Template {
  Environment getEnvironment();
  byte[] renderToImage();
  String renderToString();
}

Let's say renderToImage() is a convenience method which uses renderToString() to output the image. If I have to create a class which only needs to implement renderToString(), what would be your solution?

Check here the java docs help me understand even the most complex of definitions:http://docs.oracle.com/javase/tutori.../abstract.html another good def:http://www.roseindia.net/help/java/a...-keyword.shtml

Please don't quote Roseindia, they are content thieves.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I'll try to explain this with an example. Let's talk about a simple templating system which is based on a single Template interface. Every different template implementation has a different way of interpolating variables, convention used for representing data etc. But all templates also share a common piece of logic: they all interact with the "environment" i.e. state, they all are capable of being serialized to common formats like PDF, PS etc.

My concern as a template framework provider would be to prevent code/effort duplication for template implementers i.e. classes which provide different template support. To that end, I create a convinience base class which would be extended by all template implementers and which has the common logic required for all templates. But I have two problems:

  1. I can't enforce template writers to override/implement a method. For e.g. I would want each template writer to override the render() method which takes a template, environment and produces a rendered output as String.
  2. I can't prevent instantiation of the BaseTemplate class.

These two problems can't be easily handed by a normal class. Enter abstract classes. You want to enforce template implementers to override a given method? No problem, just make it abstract. You want to enforce non-instantiation? No problem, make the entire class abstract.

Of course, I'll also mention that you can't have abstract methods without making the entire class abstract because as per common sense, you'll really not want to "instantiate" something which isn't complete (yes, …

stultuske commented: never been good at explaining myself :) +12
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It really makes me happy and gives a warm fuzzy feeling knowing that the small amount of guidance provided helped you in the long run. Good luck with your new job! :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You can use JUnit Test Suites to get a fine grained control on which tests get executed. Create a test suite, run it and it will automatically run only the included test classes.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This is my custom exception class. By the way, I want to create an exception for not allow the user set inches and feet to a negative number. After create my custom exception class, I implement it to my distance class like this

There exists one such exception in the Java standard library specifically for this case; it's called IllegalArgumentException which you would normally see when you try to create an ArrayList with negative size etc.

Also, the custom exception which you have created is a "checked" one in the sense that "compiler" checks to ensure that either the caller catches the exception or propagates it to a higher level. Don't use checked exceptions for something which can be easily prevented at runtime. For e.g. in your case you can always check the parameters before passing them to the Distance constructor. Or better yet, just throw a unchecked exception (like IllegalArgumentException mentioned above).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You need to add a type parameter to Distance class only if you have generic types as members of the class. A good example for such a class would be "Node<T>" of a linked list which holds a value of type "T" along with a reference to the next node

class Node<T> {
  private T item;
  private Node<T> next;
}

In your case, you need not make your class generic. You can simply do:

class Distance implements Comparable<Distance> {
  public boolean compareTo(Distance that) {
    // code here
  }
}

I also have a question about generic class. If I make it generic and I have an inch and feet variable. Shouldn't I make it

Nope, the type parameter for the Comparable interface is the class which implements Comparable and not the type parameters of your class.

The last question is about equal method, I don't quite the code you just type up there. I don't understand. Can you explain it a little bit.

Which part specifically? I'm just pointing out that you are missing a condition which will help with "fast" execution of equals in case you pass the same object into the equals() call. For e.g. with your current equals() method, if I do:

Distance d = new Distance();
boolean status = d.equals(d);

The equals() call would go ahead and compare the fields when there is no real need to do so given that we know they are the same objects in memory pointed to …

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> a reason why you yourself would/could use private constructors, is implementing the Singleton pattern

As a safety measure, if your class shouldn't be instantiated, make sure you throw an exception from the private constructor otherwise it is pretty much open to reflection abuse.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Your `compareTo` method isn't proper. In compareTo, you don't create "new" objects but compare the object on which the method was invoked with the object which was passed in. Your current code doesn't work because "k" should ideally be the "this" object. Also, your assignment to "k1" is lost/meaningless since you again reassign with the cast of "obj".

Also, make sure you use `Comparable<T>` where T is the type you are comparing instead of simply Comparable (given that Comparable is a generic interface). This will help you get rid of the cast.

Your hashCode() can be made a bit better by following the code which is used by most hashCode() implementations of the standard library. Something like:

@Override
public int hashCode() {
    int prime = 31, result = 1;
    result = prime * result + ft;
    result = prime * result + in;
    return result;
}

Your equals() method is missing a inexpensive check to make sure that if equals() is invoked on the same object, it returns without checking anything.

public boolean equals(Object that) {
  if (that == null) return false;
  if (this == that) return true; // -> missing this
  // remaining code
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> but it would be nice to know that the money got through

Hover over your avatar in any post you make and you should see a "sponsor" badge. Also, try accessing "Area 51" in community center after "clearing your cookies". If these two are as expected, then your payment has definitely gone through.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Because mathematically, 10.1 is the same as 10.10 which is the same as 10.100 and so on. You might want to elaborate a bit on the context here to get useful answers.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A label in Java can be used for regular code blocks and IF statements along with their regular usage with looping constructs. So you can have:

something:
if (i == 1) {
  method();
  int j = method2();
  if (j == i) {
    break something;
  }
}

Similarly with blocks:

something: {
  method();
  int j = method2();
  if (j == i) {
    break something;
  }
}

Do keep in mind that "continue" can only be used from within looping constructs considering that's the only place it makes sense.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

We have been recently hit with a spam wave which resulted in the admins banning a few IP ranges to stop the onslaught. It's a possiblity that your IP address was caught in the cross-fire and hence shows the given message.

Once the admins are online, they should be able to have a look and bring things back to normal. Nothing serious here. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What I ment was that in each project (both the lib and the main program) do I have to have that com.stuct package and that Global class with var?

No, having it in one place would be fine. Let's suppose that you have the `Global' class in the library project (called for e.g. jlib). To then use it in your other project (called jAwesome), you'd:
* Import the Global class in any class of the jAwesome project
* Make sure your dependencies are set right. If you are using an IDE (e.g. Eclipse), you can make a project depend on another project
* If you are compiling from command line, make sure you use the -cp switch of `javac` command to specify the jar file of the library project.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Look into the "connect()" method of the `Socket` class. Basically, you create a blank socket and ask it to connect to a given destination with a specific timeout. This connect() call blocks until a connection was made or timeout was encountered.

// untested
final Socket sock = new Socket();
final int timeOut = (int)TimeUnit.SECONDS.toMillis(5); // 5 sec wait period
sock.connect(new InetSocketAddress("host", 8080), timeOut);
Majestics commented: ............................................................................................. +8
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Dani is furiously working towards rolling out brand new Daniweb website written from scratch. You might want hold off your suggestions and bring them out when she is again in "accepting new feature requests" mode. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ah, no particular reason. I was assuming the actual code has a real iteration over some items (as opposed to while true) in which case it's better to put the interrupt check in a separate IF statement inside the outermost loop.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

From your first post, drop the extends Thread. If you want to submit a task to the pool, just make your task implement Runnable or Callable instead of extending Thread.

Also, a clarification - you are not cancelling "threads" but cancelling the "future". This is a big difference because if you use a fixed thread pool, a single thread will be used to execute multiple tasks and in turn return multiple futures.

Now, the simplest solution to actually stop a computation is to "listen" to interrupts.

public Task call() {
  while (true) {
    if (!Thread.currentThread().isInterrupted()) {
      // do something
      System.out.println("Hello world");
    }
  }
  return this;
}

The reason it works if you put sleep() is because, sleep is a blocking call which throws an interrupted exception when the sleeping thread is interrupted from outside. Though sleep works, it's not a good solution because it most probably toggles the thread state as opposed to just checking the interrupt flag.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The "build" folder shouldn't be part of your JAR file. Also, make sure that the KTest2 class has a main (entry point) method.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Have you checked the JAR file to ensure the manifest really is there? Make sure you are invoking a JAR command which "packages" the manifest file in the JAR. Ensure there is a newline after the last manifest attribute. Read this. Follow up if it still doesn't work.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't think this solves anything if your purpose here is to "cancel" the underlying computation. Create a task which continuously (while true) prints "Hello world" to the console (STDOUT) every second and set the timeout for that task to be 5 seconds. You'll notice that even after the task has been cancelled, you still get "Hello world" printed to the console. Why? Because, cancel() on Future *attempts* to cancel the underlying computation. Sure, you have expressed your desire that you don't need the future, but this doesn't mean that the "underlying" processing has stopped.

To summarise, unless your "task" is thread interrupt aware, calling cancel(true) has no effect on the computation. If you are iterating over a *large* number of element, with some processing done for each element, you are in luck since you have time window for polling the interrupt status of the thread. If you are invoking a blocking call like doing traditional I/O, you are out of luck and the only way would be to forcefully close the I/O stream/handle.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAICT, the web client works across all browsers (assuming you have no "blocking" plugins installed). Give this link a try and let us know how it goes.

PrimePackster commented: Thanks +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

My bad, I meant javac. What does javac -version print? Also, does it work when you use javac -source 1.6 -target 1.6 compute/Compute.java compute/Task.java ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

We need more details. What is the command invoked to "build" the JAR file? Which version of Java do you have on the Linux box? This error normally comes up when you try to compile code containing generics using pre 1.5 source level.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't think there is a clean way of doing this in RMI given RMI doesn't offer an appropriate level of "socket" abstraction for this sort of stuff. Your best bet would be to pass a "callback handler" when "registering" or "joining" the chat. When the server wants to kick a client, it will just use the callback handler for that client (maybe stored in a Map at the server, name -> callback handler pair) to invoke the "kick" method. This kick() method will then be called in the "client JVM". In that method, you can "NULL" out the reference for the chat server.

Your client now no longer has the reference to the server and will have to make another call to "join" the chat. Just make sure you also call System.gc() and System.runFinalization() to ensure that the distributed garbage collector (DGC) kicks in and performs the necessary cleanup.

Some sample code:

public interface CommandHandler extends Remote {

    void kick() throws RemoteException;

}

public class CommandHandlerImpl extends UnicastremoteObject implements CommandHandler {

    private final Client client;

    public CommandHandlerImpl(Client client) {
        this.client = client;
    }

    public void kick() throws RemoteException {
        this.client.chatService = null;
        System.gc();
        System.runFinalization();
        System.out.println("You were kicked from the server, please reconnect!");
        
        // update UI by clearing out all text boxes, list boxes etc. so that the user gets
        // the impression that he was "actually" kicked out.
    }

}

// Your main application class which has the chat server reference and …
Ezzaral commented: Nice solution. +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I'm not sure what's the confusion here:

// add same elements twice; should be added only once
set.add(i1); 
set.add(i1);

// add new element; size is now 2
set.add(i2);

// remove added element, size is now 1
set.remove(i2);

// remove a non-existent element, shouldn't affect set
// size is still 1

// this part performs auto-boxing i.e. i1 now points to a new Integer object 
// having value 47
i1 = 47; 
set.remove(i1);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I posted a sample code. My point was that you just need to make sure you are passing a type parameter when creating JComboBox and you should be good to go. Something like:

JComboBox<String> comboCity = new JComboBox<>(temp);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

my part of code give me message to recompile with -Xlint:unchecked
How to fix this code so the message gone

JComboBox was made a generic type in Java 7 so creating a new JComboBox without supplying the type parameters would result in the usual "unsafe" warning. The solution here would be to specify the type parameter when creating the combo box, something like:

import javax.swing.*;
public class Test {

    public static void main(final String[] args) {
        final String[] strs = { "a", "b", "c" };
        final JComboBox<String> cbox = new JComboBox<>(strs);
    }

}
mKorbel commented: Object not String +10
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ok thanks and happy new year.
when i said "when i'll master them" i meant when i'll master the core language.
I wanna develop programs that can connect to the internet, ping, scan network, etc.
So which language is most used for these kind of stuff ??
thanks again

The general rule of the thumb is to have knowledge of:

  1. A language close to the metal and generates fast and native code. C or C++ are good contenders for this category.
  2. A language which can be used to execute quick n dirty tasks and prototyping. Python, Ruby or Perl fit nicely in this category
  3. A language which can be easily used to put up a web application without much fuss. Again, Python and Ruby are good contenders for this category.
  4. A language which has awesome commercial support, public following and guarantees job security. Java and C# along with their frameworks/libraries are good contenders for this category.
  5. Knowledge of the "shell" for the OS you work on. Shell scripting on *nix and Powershell for windows (or bat scripts if you are brave enough) fall in this category.

After that, feel free to learn any more languages which you learn to broaden the scope of your skills and knowledge.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I had a look at this thread and it seems that you don't need entire Access suite installed just for using MS Access. You might want to try the links mentioned in the thread.

BTW, any reason you are stuck with Access? Is there any reason you can't use a pure Java database like H2 or HSQLDB or Derby?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I've just learned that Java's 'protected' access specifier has a different effect than that in C++. So is there a way to make a member of a base class visible to its inheritors but not globally?

Assuming by globally you mean "other classes in the same package", then no, there is no way to get around this behaviour. Is there any specific problem arising from this that you are trying to solve?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That's a problem because when compiling for 1.4 target VM, the compiler doesn't know about var args. The solution is to change the compliance to at least 1.5 (1.6 would be recommended). I would suggest to change the workspace compliance level and make sure you don't override workspace specific compliance when creating a new project.

In Eclipse go to: Window -> Preferences -> Java -> Compiler -> JDK Compliance -> Change drop down to 1.6 and check the 'Use default compliance settings'.

For your project, right click -> properties -> Java Compiler -> uncheck enable project specific settings -> OK

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Is there anything wrong with this? Thanks.

No, looks good. Do you have multiple Java versions installed? If yes, can you check which one is used by Eclipse? Also, can you check that the compiler compliance level for your project in Redhat Eclipse is >= 1.5 by going to "right click project -> properties -> java compiler"? Also, can you try compiling the class mentioned in your first post using the command line "javac" rather than using Eclipse?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Variable arity (var-args) are a Java 5+ feature but is implemented under the hood as an array. If you have a Java 1.4 compiler trying to compile the code calling a var args method, there is a possibility of getting this error. Are you sure the setup on CentOS (both Eclipse and Java installation) is using Java 5+ ?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There is one more change which I missed out in my previous post. Also, make sure that you use a UTF-8 aware output stream for writing out the arabic text. E.g.

final PrintStream out = new PrintStream(System.out, true, "UTF-8");
out.printf("Welcome to the Grade Book Dr. Sherif!  for \n%s!\n", courseName);

Windows is bit quirky when it comes to encoding. These changes pretty much work on Ubuntu but I'm not sure if they would on Windows (which doesn't have an option for setting a global encoding).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I don't know the types of the keys or values

I'm not sure I understand. For a newly created raw map using reflection, there is no way of "retrieving" the type information without querying the actual contents (unless using type tokens). Something like:

Map<Object, Object> m = (Map<Object, Object>) map;
for (Map.Entry<Object, Object> e : m.entrySet()) {
    Object k = e.getKey();
    Object v = e.getValue();
    System.out.println("Type of key: " + k.getClass().getName());
    System.out.println("Type of value: " + v.getClass().getName());
}

It would be easier to help you out if you can hack together a small compilable test program which demonstrates the problem you are facing.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAICT, if an explicit charset is not provided, Scanner class uses the default Charset when parsing the input stream. Two things you can try out:

  1. Add a SOP to the start of your program to print the default charset being used by adding the line: ` System.out.println(Charset.defaultCharset().name()) ` at the start of your program
  2. Change Scanner constructor to take in a explicit character set i.e. ` new Scanner(System.in, "UTF-8") `

If it still doesn't work, post a screenshot of how the session looks like (after hiding personal information of course).