r/javahelp • • Mar 07 '20

New to java, and need some help.

1 Upvotes

Hey boys, im pretty new to java and im just trying to fix this no-arg constructor compile error.

-----------------------------------------------------------

src\com\rs2hd\model\NPCDrop.java:13: error: missing method body, or declare abstract

public NPCDrop()

----------------------------------------------------------

Here is the code.

----------------------------------------------------------

package com.rs2hd.model;

import com.rs2hd.util.XStreamUtil;

import com.rs2hd.util.log.Logger;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

public class NPCDrop {

public NPCDrop();

public static Map<Integer, NPCDrop> npcDrops = new HashMap<Integer, NPCDrop>();

@>SuppressWarnings("unchecked")

public static void load() throws FileNotFoundException {

List<NPCDrop> list = (List<NPCDrop>) XStreamUtil.getXStream().fromXML(new FileInputStream("data/npcDrops.xml"));

for (NPCDrop drop : list) {

npcDrops.put(drop.getNpc(), drop);

}

Logger.getInstance().info("Loaded " + npcDrops.size() + " npc drops.");

}

public static NPCDrop forId(int id) {

return npcDrops.get(id);

}

public class Drop {

private int chance;

private Item[] items;

public int getChance() {

return chance;

}

public Item[] getItems() {

return items;

}

}

private int npc;

private Drop[] drops;

public int getNpc() {

return npc;

}

public Drop[] getDrops() {

return drops;

}

}

--------------------------------------------------------------------

If you can provide an insight that would be fantastic, thank you.


r/javahelp • • Mar 15 '20

Java vs java script

1 Upvotes

I really want to learn to code, but I was wondering what kinds or programs can I make with java and what programs can I make with java script.


r/javahelp • • Jan 13 '25

DSA with JAVA

1 Upvotes

Where can I get the best resources for DSA in JAVA? I know the basics of JAVA,now I want to start doing DSA in JAVA.


r/javahelp • • Mar 29 '24

How is this void method returning a value

1 Upvotes

I am studying quicksort algorithm and i came upon this code, how is the method returning the sorted array when it is a void method, any help is appreciated.


r/javahelp • • May 19 '24

Core Java Banking app

0 Upvotes

I have to make a banking app(on console) with feature like withdrawal and deposit and account info using core java concepts like loops,threads, exception handling,file I/O etc! Plss help me with what I have to do!

Code is in comments!


r/javahelp • • Apr 17 '24

Change in Tech Stack Js -> Java

1 Upvotes

I’ve been working with Node Js and Express close to an year now, now my company wants me to learn Java and Spring boot, if I start learning this my last 2 years are waste and need another year to have some experience in java, What should I do ?


r/javahelp • • Nov 03 '20

Can someone help me with this, I’m so dumb. 😭😭

0 Upvotes

create a program that computes and displays a game character's attack speed at a certain level. Use the formula below.

Current attack speed = Base attack speed * (1 + (Bonus attack speed % * (Level - 1)))

The variable for level should be of int type. The bonus attack speed % should be converted to decimal (divide by 100) before multiplying by the level. For example, if the user enters 4% for the bonus attack speed, the formula will use 0.04 instead of 4. Round the current attack speed to the nearest three (3) decimal places.


r/javahelp • • Dec 12 '19

Adding values to 2D array

0 Upvotes

Hi all, I have a 2D array with 20 preset values, but as part of the project we need to add up to 100 values Here is my code as follows

Public static void PrintDiggerDetails() { String [][] DiggerList = new String[99][7]; System.out.println("==Digger Data Table=="); (Next part covers headings for printing array) System.out.print(DiggerList[0][0]"Manufacturer"); System.out.print(DiggerList[0][1]"\t\tYear"); System.out.print(DiggerList[0][2]"\tPrice"); System.out.print(DiggerList[0][3]"\tArmLength"); System.out.print(DiggerList[0][4]"\tTrack Type"); System.out.print(DiggerList[0][5]"\tStatus"); System.out.print(DiggerList[0][6]"\tWeight); } (Below this all the preset values are stored down to [19][6]) I then have a method: static void AddNewDigger() { Scanner disc = new Scanner(system.in) String strPrDOpt; strPrDOpt = disc.nextLine(); System.out.println("Manufacturer: ");

System.out.println("Year: ");

System.out.println("Price: ");

System.out.println("Arm length : ");

System.out.println("Track type: ");

System.out.println("Status: ");

System.out.println("Weight: ");

How do i add to the 2D array using these values please

}


r/javahelp • • Apr 15 '22

Can split be used on ArrayLists?

0 Upvotes

I'm doing a coding assignment that requires removing elements from a certain index in an array, so I thought I'd use an arraylist. However, I'm having trouble splitting the arraylist into parts which I can interate through. I tried first using a regular array, splitting it, and then converting it into an arraylist but even that still isn't working. Any advice?


r/javahelp • • Mar 07 '13

Rewriting Unix in java?

0 Upvotes

Hey guys!

I'm doing an assignment right now in class where we have to create the unix 'cat' code, but in java, and me n my friend are soooo stuck...

does anyone have any ideas??

Thanks! :)


r/javahelp • • Apr 10 '14

Learning java and having trouble, is my teacher bad or am I just not getting it?

0 Upvotes

I normally have no problem teaching myself things with the internet, I've had to teach myself quite a bit of stuff during my "intro to programming" class that I'm taking.

I'm starting to run into problems where I don't know if it's me not understanding things or if the teacher is so bad at explaining them that I'm having trouble following. I get the feeling it's because he's trying to dumb it down to a point that people understand it better and don't drop the class. He didn't teach us how to make a graphics window appear before we started learning how to draw the pictures on the screen.

A lot of the homework is taught in "snippets." As in "write the snippet of code that does this." But I'm not learning how to apply it in a java source code.

I've been getting 100's on everything thus far, but this homework has me stumped, and I don't know if it's his formatting in his lecture notes, or if it's because when he lectures in class, he just kinda skims through his slides because he's been using the same ones for years.

This is a link to the homework I'm currently working on: http://walshe.faculty.mjc.edu/Virtual/IntroToProgramming/homework/homework12/homework12.html

I'd like if someone could take a look at it, specifically questions 1-8, using his "UML-Like" diagram and tell me if you can make heads or tails of it.

These are the answers I have so far.

  1. MultiplyTwoNumbers myObject = new MultiplyTwoNumbers(1,2);

  2. System.out.println(number1);

  3. System.out.println(number2);

  4. Int firstNumber = myObject.number1

  5. myObject.number2 = myobject.number2 + 1

  6. System.out.println(getProduct);

  7. Int myProduct = myObject.getproduct

If his homework is understandable, and these are wrong, please tell me why, I'm really trying here. If they're right, I'd also like to know why, I feel like I'm blindly writing things down hoping it's correct with very little understanding of how it actually works.

I've spent an hour on question 8 trying to read through past lectures to figure out why I'm not getting it. I just feel if he would teach us proper java instead of handing us half of the work, not explaining how it does what it does, and then expecting us to figure out on our own to fill in the blanks, I'd understand this. Hell, even some internet tutorial would be useful at this point.


r/javahelp • • Mar 02 '15

I can't seem to add a jpanel to a jframe

0 Upvotes

Is there some trick to do it?


r/javahelp • • May 04 '14

So I wrote this program

1 Upvotes

I wrote a program utilizing the Selenium Webdriver API to scrape and download articles from a collegiate online database. Should I make it user-friendly (ie, not just a glorified script but an actual distributable program), and up it to github? What are would you suggest I do to make it more amenable to others? Does it need a GUI? It uses password authentication, so which non plaintext password store would you recommend?
Thank you


r/javahelp • • Feb 24 '15

College Project

1 Upvotes

Alright so im in an intro java class, and we got partnered on a project and my 2 partners are completely clueless on how to do java coding, i have a very small minute experience. I got assigned the part of making a custom package, class, and method to show to the class. How would i go about this? My teacher says that if i can find one online and explain it I could do that but im clueless what to do as just 4 weeks ago i was learning how to get CMD to say hello world.


r/javahelp • • Oct 31 '15

Help with finding the SDK used for a program

1 Upvotes

So this is the source code here:

https://github.com/Hohol/TetrisPlayer Got from here

Just wanting to test out the program as it is ridiculously impressive, if anyone could make it into a usable program that'd be more than I could ever wish for.

Thanks :)


r/javahelp • • Feb 18 '15

Sorry a very simple question, If I add an object to a ArrayList and I have a reference to the object outside the add function, if I modify the object, does the object get modified inside the list too?

0 Upvotes

Basically, does Java simply reference to established object, or does it clone it?

I'm guessing the former, though just to confirm, I want to know this.


r/javahelp • • Jun 24 '23

Unsolved Help on how to proceed further with a Servlet / JSP / SQL project or task. I'll appreciate help. My employment depends on it.

1 Upvotes

My post is pasted here: https://pastebin.com/fQd50nxf


r/javahelp • • Jul 03 '23

Unsolved Arrays, please help

0 Upvotes
System.out.print("Enter number of boxes: ");
	int boxes = scanner.nextInt();
	String[] numberboxes = new String[boxes];
	int[] gifts = new int[boxes];		
	for (int i = 0; i < boxes; i++) {
 // Here is where I'm missing the code to show the number of the box               the user will give the info
		System.out.println("Box number" //the code to show box n1, then n2...etc until it reaches the number of boxes the user gave );
		System.out.print("Gifts in the box: ");
		gifts[i] = scanner.nextInt();

Hello!! Above I copied the practice program i'm doing in java, working with arrays; I'd like to get info from every box, and show the box number i'm getting that info from, number that the user previously entered.

Thank you in advance. I'm a begginner so appologies if it is a dumb input i can't figure it out.


r/javahelp • • Jun 27 '23

Should I learn Maven/Gradle?

1 Upvotes

Throughout my 3 years of Java, I have only been taught to use Apache Ant when creating projects. I see a lot of talk of needing to know either Gradle or Maven, and i was wondering if i should take the liberty to ditch Ant to learn one of the newer build tools.

Resources to learn would also be appreciated!!


r/javahelp • • Aug 24 '24

how to understand Java Collection Frameworks ?

0 Upvotes

in my Java backend learnings, I have created projects and learned Java, Spring Boot, JDBC, and many other things but I find it difficult to grasp Java collections, I have used it while using projects as needed, but I don't know anything, so how should I learn that I want to solve basic questions for interview purpose(definitely not competitive level just basic), any resource or ideas appreciated.


r/javahelp • • Apr 12 '17

How to read data from table?

0 Upvotes

Hi, I want to read and write data from a table.but i don't know how to use it.Anybody give a suggestion?


r/javahelp • • Oct 02 '15

tl;dr How to highlight variables beginning with $ in JCreator?

1 Upvotes

I have to use JCreator for labs in Uni and would like to highlight variables that begin with $.


r/javahelp • • Mar 24 '14

Learning Java

0 Upvotes

I would like to learn java as i am doing a computing A-level next school year. I have started using UDEMY tutorials, but i am really looking for something better and more detailed. Could someone please help me out here and also advise me whether to learn java or actually learn c# or something else. Thanks.

By the way i am an absolute novice for programming. I don't yet understand any of the logic.


r/javahelp • • Jul 27 '19

Project Panama (vectorIntrinsics), matmul performance

1 Upvotes

Pulled and compiled vectorIntrinsics branch of project Panama today.

The main OMG is that measured scope takes only 400-450ms (after C2, C1 - 700ms) for 2048x2048 matrix-matrix multiplication.

Ubuntu 18.04. Ryzen 1600x stock.

float[][] a = generate(size, () -> (float) Math.random());
float[][] b = generate(size, () -> (float) Math.random());
float[][] r = generate(size, () -> 0.0f);

// measured scope
for(int i = 0; i < size; i++) {
            int finalI = i;
            forkJoinPool.submit(() -> {
                for(int j = 0; j < size; j++) {
                    float dotProduct = 0;
                    for(int k = 0; k < size; k += SPECIES.length()) {
                        FloatVector av = fromArray(SPECIES, a[finalI], k);
                        // just assuming, that `b` matrix is transposed
                        FloatVector bv = fromArray(SPECIES, b[j], k);

                        dotProduct += av.lanewise(MUL, bv).reduceLanes(ADD);
                    }
                    r[finalI][j] = dotProduct;
                }
            });
}
forkJoinPool.shutdown();
forkJoinPool.awaitTermination(100, TimeUnit.SECONDS);

Am i missing something in the code ? Because performance is unbelievable. Does anyone has precise benchmarks results for CUBLAS, MKL for such sizes?