If you want to make the most money possible, and are OK with a much higher risk of being unemployable at some point, become a specialist. The field is a lot narrower for specialists and it can quickly become full, leaving you without work. As time progresses, it's likely need for your area of expertise will dissolve unless you are an expert in something abstract (e.g. one day no one will care much about deep knowledge of the Java language specifically, but knowledge of how a bytecode VM, JIT capable OOP language works in general will be valuable for a long time).
If you are OK with taking some "losses" in terms of how much money you'll eventually make, and prefer less risk of unemployment become a generalist. You won't be paid as much because you do not hold a scarce knowledge commodity, but you'll have a much wider field of opportunity to find jobs that want to leverage some of the knowledge you do posses.
Finally, this is all assuming you want to stay in a focused technical role your whole life. If your goal is to eventually do something else like run your own company, start becoming a generalist immediately.