r/javahelp • • Jun 15 '16

Simple question about Java's use of RAM

0 Upvotes

If I run a Minecraft server and an instance of the game, do they share the same RAM specifications? I launch my game with: -Xms1024M -Xmx4G and my server with: -Xms2048M -Xmx2048M Are they using the their own specifications?


r/javahelp • • Sep 06 '15

I need help

0 Upvotes

For my assignment I need to do this....DECLARE AN INSTANCE VARIABLE CALLED NAME THAT CAN CONTAIN A VALUE SUCH AS "EGGS"....I have no idea where to start. If someone could help me get started hopefully I can finish the assignment. Thanks everyone


r/javahelp • • Jul 04 '22

i dont understand why we are comparing a[j] and a[i], arent they the same values each time?

1 Upvotes
 char[]a = str.toCharArray();
	int j=0;

	for(int i=0; i<a.length;i++) {

		if(a[j]!=a[i]) {
j++;
a[j] = a[i];
		}

	}

	System.out.println(Arrays.copyOfRange(a, 0 , j+1));

r/javahelp • • May 13 '14

When choosing a representation to correspond to individual buckets of a hash table, when and why would you choose a map over a list?

1 Upvotes

r/javahelp • • Nov 24 '21

Codeless Eclipse or intellij?

1 Upvotes

Is intellij better than Eclipse? Which One Is more used in companies? Should i switch to intellij?


r/javahelp • • May 25 '15

Please help me, my animation wont work

0 Upvotes
    TestAnimation_pkg;

public class TestAnimation_Class extends Applet{ //

import java.applet.Applet; import java.awt.*; // import java.util.Timer; import java.util.TimerTask;

	int x=0
	int y=0;			//
	int z=0;

	 
	public void init(){
	        int delay = 250; // delay for 1/4 sec.
	        int period =   ; // repeat every 0.25 sec.
	        Timer timer = new Timer();
	        TimerTask task = new TimerTask() {
	            int count = 0;
	            public void run() {
	                System.out println("doing");		//
	                Toolkit.getDefaultToolkit().beep();	//
	                repaint();
	                count++;
	                if (count == 0){		//
	                    cancel();
	                }
	            }
	        };
	        timer.scheduleAtFixedRate(task, delay, period);
	}
	 
	public void stop(){}

public void paint(Graphics g){
	x=x+4;				//
	y=y-4;
	 
	g.setColor(Colour.red)	//
	 
	g.fillRect(x, ?, 50, 50);	//
	 
	}

	 

	}				//

r/javahelp • • Dec 01 '19

Review my small chapter on Java (Beginners book)

0 Upvotes

Hello everyone, I'm writing a book designed for people who are looking for a career in Software engineering. One part of the book covers a collection of programming languages that are popular in today's industry. Each chapter covers a language in a very brief (not going into too much detail) format:

  1. Relevant Quote

  2. Language introduction - Talks about how it came into fruition and a brief explanation of what it is and how it gets used.

  3. Code example - Here is provided with a small code example just to give the reader a taste of the language's syntax and features.

  4. Use cases - cover one or more of the following: types of developers that use it, what industries use it, what platforms and project examples.

  5. Did you know - is a dumping ground for some interesting facts about the language.

I wanted to run this chapter past the subreddit Java to see if there is anything you guys would add on any of the sub-sections listed above -- to capture the language in the best way. Or highlight anything that is inaccurate/wrong. Thank you!!

## Java

> "Java is C++ without the guns, clubs and knives."
>
> -- _James Gosling - Creator of Java_

---

### Language introduction

Java is used by 90% of Fortune 500 companies as their server-side language. It's the official and original language for development with the Android platform. From laptops to data centres, game consoles and scientific computers use it. It exists in a lot of places.

Java is an object oriented language like C++ and C#.

### Code example

In the Investment world, a customer can create as many pots as they'd like. So if the back-end engineers create an 'Investment Pot' class, it can be used again and again to model pots of a real customer.

Here is a contrived example of an Investment Pot.

#### ![Script icon](./images/script.png){ width=75px height=75px } InvestmentPot.java

```java
class InvestmentPot {
  private float total;

  public InvestmentPot(float total) {
    this.total = total;
  }

  public void addContribution(float contribution) {
    // add the new contribution to the total cash pot value
    this.total += contribution;
  }

  public String outputTotal() {
    return "Total pot value is " + this.total;
  }
}
```

Above the pot can store the total cash amount that a pot has, and we have exposed a behaviour/method/function that allows people to add more money/make a contribution.

We usually have a main entry-point into the application. The code below will be fired first when running the application.

#### ![Script icon](./images/script.png){ width=75px height=75px } App.java

```java
public class App {
  public static void main(String[] args) {
    float startingAmount = 2000;
    float contribution = 250;
    // We are creating a new object of
    // our InvestmentPot class blueprint
    InvestmentPot myPot = new InvestmentPot(startingAmount);
    // calling the method below
    myPot.addContribution(contribution);

    System.out.print(myPot.outputTotal());
  }
}
```

### Use cases

Java is extremely popular. There are more than 9 million Java developers in the world and the odds of getting a job are quite high. According to indeed.com -- at the time of writing -- Java is the top language for job postings.

- Build Android apps
- Build software tools
- Enterprise applications
- Used by NASA (One application zooms in from outer space and can examine a location on earth)
- Used for self-driving cars
- Math-oriented applications (Scientific processing with visualisers)
- One of the main choices of Academic study for Computer science.

### Did you know

Java was created back in 1995 - meaning it's one of the oldest programming languages in motion.

Java gets downloaded more than a billion times each year.

Java's original name was OAK. The creator James Gosling named it after the oak tree he saw outside his office window.

Google and Oracle had to settle a \$9 billion copyright lawsuit around the use of Java -- a language owned by Oracle. Google had incorporated 11,500 lines of Oracle's code into the Android platform.

r/javahelp • • Feb 21 '19

Need help with Java Code!!!

1 Upvotes

Here is my code:

import java.util.Scanner;

public class VowelCount

{

public static void main(String args [])

{

int a = 0, e = 0, i = 0, o = 0, u = 0, other = 0;

String text;

Scanner scan = new Scanner(System.in);

System.out.print("Enter a string of characters: ");

text = scan.nextLine();

for (int z = 0; z < text.length(); z++) {

char c = text.charAt(z);

if (c=='a')

{

a++;

}

else if( c=='e')

{

e++;

}

else if(c=='i')

{

i++;

}

else if(c=='o')

{

o++;

}

else if (c=='u')

{

u++;

}

else

other++;

}

System.out.println("Number of vowel in the string: ");

System.out.println("a: " + a);

System.out.println("e: " + e);

System.out.println("i: " + i);

System.out.println("o: " + o);

System.out.println("u: " + u);

System.out.println("Number of non-vowel characters: " + other);

}

}

The code runs perfectly, but how do you add a do while loop to repeat this process?

TL;DR: How do you add a do while loop to repeat this process?


r/javahelp • • Feb 01 '22

Codeless If you can and want to help me

0 Upvotes

Hi guys and girls, I am a first time poster here and I hope I'll find here what I'm looking for. I am curious about Java and I have already read some scripts about Java language but I am still a noob and I news help. I was thinking of making a script in Java that'll help me on downloading music from Youtube (Like a Youtube downloader) but like I said I am still unexpirienced so I had in mind that you guide me. I want to type every character od the code myself but I think I news guidance. For example you can tell me which commands I'll news for this kind od experiment? Etc. Etc.

Thanks in adavance to you all.


r/javahelp • • May 17 '20

What is a hash?

0 Upvotes

Need a body to post.


r/javahelp • • Sep 21 '16

does this code compile? why or why not?

1 Upvotes
class Hello{
    public static void main(String[] args){}
    private int main(String[] myArray){}
    }

**Does it have something to do with having the same constructor name?


r/javahelp • • Jul 20 '21

Java Error

0 Upvotes

i have just started learning and writing a sample code to convert gallons into liters, i wrote below from a book

class Example4 {
public static void main(String args[]) {
double gallons = 10.0;
double liters=gallons*3.7854;
System.out.println("10 gallons ="+liters+"liters");
}
}

but when i do javac Example4.java. i get following error, i can't understand where did i make mistake in such a simple code

Error:

':' expected

javac Example4.java


r/javahelp • • Mar 07 '22

HashCodes... Yes... we know... "equal Strings == Equal hashCodes!!1!".

0 Upvotes

Of course, if 2 strings are equal the hashcode will be the same,

Of course, if you use the hashCode as a persistent ID (for Database or whatever) is a bad idea, but I feel these obviously bad implementations of hashCode muddle every valid implementation the hashCode functionality may have.

What about the innate hashCode of a Java object, No one seems to succinctly address this, do the JVM even keep a registry??

If we need to "care about the hashcode" and "stop using it as an object id", then Why do we even use HashMaps or Sets, do they do something to prevent collisions? , and if they do, why isn't that handled at object instantiation...

By definition if the hashCode() method of an object is as unsafe as it is meant to be, then all those classes should also be unsafe.

Most of the claims of hashCodes being bad as an id, are so vague and allude to the same two examples, that one is left completely unconvinced about it, why would sun make something so untrustworthy?

The only... only believable claim I've seen online, is the one based on the birthday paradox which states that once there are 77 163 objects you have a 50% chance of getting 2 equal hashCodes.

Again, this is a room full of guests, what if within that room you have a bathroom??? What are the chances of getting 2 random people in that bathroom with the same birthday, I bet hashCode is extremely useful on that bathroom alone???

Does this mean that Java becomes completely useless once 77 163 items are created?

Do the JVM even keep a registry of each hashCode created so that it keeps this 50% in check and keeps the chances low??


r/javahelp • • Jan 29 '20

Coding Bat Pt. 2

1 Upvotes

I've updated my Coding Bat repository on GitHub.


r/javahelp • • Aug 08 '22

HELP!!!! I gotta get this done today, I wrote a working program for both of these, but my teacher says it's not recursive.

1 Upvotes

Problem I:

Write a static recursive method that computes the sum of the integers between two numbers k1 and k2 (including both k1 and k2).
For example, the sum of the numbers between 1 and 5 is 1+2+3+4+5 = 15.
Test your method in a program that prompts the user to input both integers and then print out the sum of all the integers between the two numbers.

import java.util.Scanner;//importing scanner

public class chp11_1

{

public static void main(String\[\] args) //main method

{

	Scanner keyboard = new Scanner([System.in](https://System.in));//obj scanner

	System.out.println("Please enter the first number(k1): ");//output

	int k1 = keyboard.nextInt();//saving input to variable

	System.out.println("Please enter the second number(k2): ");//output

	int k2 = keyboard.nextInt();//saving input to variable

	

	int sum = 0;//declaring variable

	for(int n = k1; n <= k2; n++) //for loop adding up the number 1 through 5

	{

		sum = sum + n;

	}

	

	System.out.println(sum);//outputting the sum



}

}

Problem II:

Write a static recursive method that returns the sum of the integers in the array of int values passed to it as a single argument.
Test your method in a program that prompts the user to input the length of the array, and then has them enter the int at every index of the array. Then, it should print the sum of the array using the recursive method you wrote.

import java.util.Scanner;

public class chp11_2

{

public static void main(String\[\] args) //main method

{

	Scanner keyboard = new Scanner([System.in](https://System.in));//obj scanner

	System.out.println("Enter the number of numbers you will enter: ");//output

	int nums = keyboard.nextInt();//declaring a variable for input

	

	int\[\] array = new int\[nums\];//creating an array for the numbers

	

	for(int n = 0; n < nums; n++) //for loop that adds the numbers to each index

	{

		System.out.println("Enter number " + (n + 1));

		array\[n\] = keyboard.nextInt();

	}

	

	int sum = 0;//declaring variable

	for(int n = 0; n < nums; n++) //for loop adding up the number 1 through 5

	{

		sum = sum + array\[n\];

	}

	

	System.out.println(sum);//outputting the sum

}

}

Previous


r/javahelp • • May 09 '25

I need help

0 Upvotes

Can somebody help me to learn Java and get job ready. I have completed my second year this month and I'm clue less about actual coding. I want to become job ready at the end of the third year but don't have any idea from where to start or how to start so can someone please guide me


r/javahelp • • Mar 05 '25

I need to have a GUI that would not block while debugging

1 Upvotes

I am developing a library, and I am trying to implement a feature that would ease debugging, by visualizing certain components of it. I need the visualization to work when I set a breakpoint in the main thread, meaning it would not crash and I would be able to engage with the ui. I really want it to work when evaluating an expression in a paused state when debugging.

I tried swing and it blocked no matter what I did. Considering javaFX but it seems it is also single threaded by design so it will probably block as well.

Not sure tho, hopefully you guys will have some insights here, thanks!


r/javahelp • • May 04 '26

java compilation problem, class can't be found though on the same package

1 Upvotes

both Verbose.java containing the verbose class and test.java are located on the same package, but I still receiving this log error when I try to compile, how come? test.java:4: error: cannot find symbol

Verbose verbose = new Verbose();

\^

symbol: class Verbose

location: class test

test.java:4: error: cannot find symbol

Verbose verbose = new Verbose();

^

symbol: class Verbose

location: class test

2 errors

error: compilation failed


r/javahelp • • Aug 18 '26

Should I have to be very good at this topic ?

0 Upvotes

I have been learning java deeply in the recent times....... hoping to crack a 10+lpa job so please guide me through this.

1 . Should I have to be very good at this topic ? or the basic understanding of these topics are enough for cracking faang companies .

  • Writing basic recurrence relations

  • Master Theorem basics

  • Common recurrence results

  • Types of Recurrence Relations

  • Divide-and-Conquer Recurrence Relation

  • Akra-Bazzi Theorem

  • Linear Recurrence Relation

  • Solving Homogenous Linear

  • Recurrence Relation

  • Q: Find nth Fibonacci Number using Golden ratio

  • Q : Solve Recurrence Relation with Repeated Roots

  • Non-Homogeneous Linear Recurrence Relation


r/javahelp • • Jul 09 '25

Unsolved Planning to learn java

1 Upvotes

I am currently working in big MNC BPO company in gurgaon, planning to move to tech job as a java developer or something related to the field.

Is it a good choice and move?

I am 28 now, married and comes from Arts background.

Really need your help to proceed further.


r/javahelp • • Apr 03 '26

what java projects did u guys do after finishing java mooc?

1 Upvotes

title


r/javahelp • • Aug 17 '26

Guide for Concurrency in Java

0 Upvotes

Before knowing anything I just jumped directly to the source code of jdk25u. I have just started to read the javaDocs of Thread class it was so deep that all my connected logic mapped very well but now I want to code and I can't code ahhhh... Why is this problem. I can call the syntax what to use but I don't know how to apply, why to apply is there any guide for java Concurrency ??. And there is so much .. still to know. Do any dev have any guide??


r/javahelp • • Mar 28 '26

I think Im done for. I feel confused and frustrated.

0 Upvotes

I'm in my 3rd year rn (will start 4th after may).

Im learning java/ springboot, now the thing is that Ive done spring JPA and am learning Spring security.

I have no projects to my name (will create one in 2 weeks) and java and some python is all I know.

I have to learn js and other js frameworks such as react.js and all too now but Im tired. How much more do I have to learn and I don't have a lot of time.

I don't have a lot of time in my hands rn too since I'll have to start to look for internships and I'll be completing my degree in another 1 year. I feel frustrated but Ik that I brought this upon myself so can't even do anything about it.


r/javahelp • • Dec 27 '25

How to learn javaFX? I feel stuck in vibe coding and not actually learn

1 Upvotes

I feel stuck in lwarning methods, interfaces, classes that may exist for a prototype i want, AI only gives me the full code, which i dont want, i want to learn better and i dont know how and where to start