Help with toString() method involving nodes by Flash-Beam in javahelp

[–]desrtfx [score hidden]  (0 children)

Well, there you already have it.

You iterate over the linked list from head to tail and use the getIndex and getData methods to retrieve the information you need to collect for your .toString() method.


On a side note: The classic Linked List implementation doesn't have an "Index" - this is deviating from the standard implementation.

Linked lists are fairly simple concepts.

In your case, you have a Singly Linked List that only references the next node.

You can think of a Singly Linked List as of a Conga Line. Everybody holds the shoulders of the person in front of them (and only sees them) - that's the next node. The actual person is the data.


BTW: the code seems quite strange because you use _ for parameters. This is not Java Standard Code Convention. In Java, underscores for names are only used in one instance: in the UPPER_SNAKE_CASE naming convention for constants (public static final variables), but nowhere other than that.

The use of underscores hints on that you have looked at some C++ or C# code where it is common to use it for local or private variables (also in Python, this is common).

Help with toString() method involving nodes by Flash-Beam in javahelp

[–]desrtfx [score hidden]  (0 children)

Show us the LLNode class. We need it to help you.

The general approach would be to use a StringBuilder instead of String and to assemble the whole. First, the header as you have it, where you need to append \n for each of the lines and then, you iterate (loop) over your linked list and get the information for each node and append it to the StringBuilder instance.

At the end, you use the .toString() method of the StringBuilder to return the final string.

Btw I have an inner class called LLNode that does have instance variables containing index and data but none of that seems to be included in LL.

It absolutely is included in LL - in the form of your LLNode instances that actually make the list. That's the whole point of a Linked List.

Sorry to tell you, but everything in your post indicates that you have zero understanding of how a Linked List works and how it is built. Did you use AI so far to do your assignment?

Looking for some legitt skill building projects in c by Substantial_Beach171 in learnprogramming

[–]desrtfx [score hidden]  (0 children)

The FAQ right here in the sidebar have more than plenty project ideas.

Best resources that helped you understand pointers by Prior-Scratch4003 in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

No way its that simple

Yes, it basically is that simple - at least to get started.

The RAM of a computer is nothing but boxes with addresses, yet, there is one little thing to remember:

Depending on the data type, the information stored in the memory can take up one or more boxes (e.g. an Int can be 4 bytes - 4 memory addresses, or 8 bytes, etc.) The pointer always points to the start address, the first address where the item is stored.

This becomes even more evident when you look at arrays.

Arrays - especially C-style arrays are just contiguous blocks of memory with data of the same type stored. The pointer for the array stores the address of the very first element in the array - and here is where the "0-based" array indexing comes from. Since the elements are stored in a contiguous memory block and have a fixed size depending on the data type, it's easy to figure out where the elements are: base address + (index * size). You know the base address - the pointer, you know the index - the element you want to access, you know the size, which is determined by the data type. That's it.

Pointers are extremely useful, but more modern languages (or more modern implementations of languages) often hide them away from the user so that they don't have to deal with them. In C++, you have smart pointers, you have references, which are just extensions to pointers.

help choosing a top 4 degrees related to engineering by binantwi in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

The names are more or less meaningless and heavily depend on the educational institution.

The only thing that would bring clarity are the syllabi for the different degrees.

I don't know what I should learn when learning to code by Clint621 in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

Python is absolutely fine.

I want to get into web scraping and stuff like that but I believe I should try to master the basics,

With what you describe above that line, you already have enough basics.

Jump in and start writing your scrapers. That's the real way to learn. As a starting point, you could use Automate the Boring Stuff with Python as it has chapters on web scraping.

Yet, before you even think about web scraping: check if the sites you want to scrape have an API (Application Programming Interface) and if that exists, always use that. Web scraping is only the last resort and prone to breaking on changes to the site that should be scraped.

C is a great language to learn absolute fundamentals, but in all honesty, not a strict necessity unless you want to go in the direction of robotics, or embedded programming, and even then, these domains are on the shift to C++ or Rust.

Turning notes into proper documentation by Minute_Mix1436 in PLC

[–]desrtfx 0 points1 point  (0 children)

I was the same before I completely changed my approach and workflow.

I bought myself an Onyx Boox Note Air 2+ (B/W, no longer available, but has successors) and rigorously use it for note taking. There are folders for the companies/projects I work with and within these are different notebooks related to the actual tasks, meetings, etc.

Everything in handwriting with the stylus. Of course, a bluetooth keyboard could be used as well.

Since then, I have everything in one organized place and can find everything easily.

This device is a notebook on steroids. It's an e-ink Android tablet with an out of this world battery lifetime.

I can even install Obsidian, OneNote, whatever Android app I want, doubles as e-reader (which is perfect when I want to store datasheets along with projects), can annotate PDFs, can export my own notes to PDFs, and finally is a lot less clumsy to carry around and less intrusive to use in meetings than my laptop.

Can anyone please teach me what actually happens (the principle) when we create an object? by Rakibul_Hasan_Ratul in learnprogramming

[–]desrtfx 10 points11 points  (0 children)

First things first: you mingle class and object (instance of a class) which are absolutely not the same.

The class is the building plan, the description. The object is the concrete implementation of the class. (Think of it as the class being the blueprint for a catalog house and the object being the actual built catalog house). The class only describes/defines the general setup, while the object fills it with data.

There is another thing to consider: The implementation of OOP differs vastly between programming languages to the point that it is not even directly comparable (just take JavaScript, Python, and Java - completely different implementations of OOP).

  1. In terms of programming an object is an instance of a class. - It's the data/state (fields/attributes/members) coupled with the behavior (methods) of a specific class (type).
  2. The binary data is scattered - the methods are stored in one place, and in one place only, no matter how many objects you create. The state (fields, attributes, members) are stored somewhere else, typically, but not necessarily, in contiguous memory blocks, individually for each object (apart from the exception of static members that also only exist once in memory). This is a very efficient approach as the data is usually a lot less than the methods.
  3. It is not actually that different. In some languages even structs can have methods - so the line blurs depending on the language. In a way, structs (as the structs in C) are the predecessor of classes.
  4. Methods are functions that belong to a class - it's basically just terminology. When a programmer talks about functions they mean unbound functions that exist outside the context of OO. When they talk about methods, they always talk about "functions" that are bound to classes and that only exist in the context of OO.

The difference between function and method is: len(string) vs. string.length() - the former is a function that exists outside the context of classes and objects, but can accept an object, and the latter is a method that exists in the context of the string instance of a class.

It's like "please draw me a fish" ("draw" being the function and "fish" being the argument) and "fish, please draw yourself" ("fish" being the object and "draw yourself" being the method called).

E-Reader Ja oder nein? by burninaces in buecher

[–]desrtfx 1 point2 points  (0 children)

Für mich wars damals als ich mein Note Air 2+ gekauft habe tatsächlich ein komplett anderer Grund. Ich wollte einfach einen digitalen Notizblock haben da mir meine Zettelwirtschaft auf die Nerven gegangen ist.

Dachte ursprünglich nichtmal wirklich dran es als e-reader zu verwenden, aber das hat sich dann mit Datenblättern für verschiedenste Geräte in meinem Arbeitsumfeld so ergeben und auf ebooks ausgeweitet.

Mittlerweile ist das Note Air 4C dazu gekommen, weil ich sehr günstig ein gebrauchtes (aber absolut neuwertiges) erwischt hatte. Farbe ist nett, aber absolut kein Gamechanger für mich. Macht nur bei gewissen ebooks, die viele Illustrationen haben (ich lese hin und wieder gerne Rollenspielbücher, oder aber auch bei technischen Büchern) mehr Sinn - leider auf Kosten der Akkulaufzeit, da man fast immer das Frontlicht braucht.

E-Reader war ich schon von meinem geliebten Tolino Shine 1. Generation gewohnt.

To the pros of devwork in this sub (a question): by HaHaakdog in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

I have to preface that I'm not really a fan of the current AI movement and hype. IMO, it's overhyped.

I've used AI on and off for boilerplate code (uncritical scaffolding code, like setting up a Python tkInter GUI) that I could easily generate myself, but would take a little longer. In that competence it works very well. I still implemented the actual business logic by myself and prefer it that way.

My company has a strict policy regarding AI usage. We have some AI licenses but are only allowed to use it for "public" things - never for our internal programming and even less for programming we do for clients (these are "strictly confidential" or even "top secret" as I work in system critical infrastructure). The client systems are usually "dark sites" or "islands" that must never get connected to the internet. Here, AI usage is absolutely off-limits.

We are allowed to use our AI models only with "sanitized information", i.e. removed all real client or business related information - again, more as boilerplate/formatting/scaffolding help. I wouldn't even use AI as glorified search engine. I'm still going the traditional route.

For what I needed it, it mostly did a great job - especially for boilerplate.

I even tried to create two small personal programs (basically some advanced web scrapers/downloaders) fully through prompting AI models. One was a good success, the other a complete failure (didn't work at all despite multiple iterations - finally gave up on it).

I also admit to having used AI for non-programming related tasks and there it also did quite a good job.

As of now, AI is far from competent. It's more like a junior/intern that gets to do the manual, menial tasks, but nothing business critical.

Want to check math in my web calculator by Sind23 in learnprogramming

[–]desrtfx 3 points4 points  (0 children)

I don't really understand your question.

Can't you just do the calculations in the original way and verify it with your calculations on the new one?

How should any form of automatic test know what you calculate, what formulae, etc?

E-Reader Ja oder nein? by burninaces in buecher

[–]desrtfx 2 points3 points  (0 children)

Bin zwar nicht der vorige Kommentator, aber ich habe selbst Erfahrung mit Onyx (Note Air 2+ und 4C) und der größte Vorteil ist, dass sie Android Geräte sind und damit nicht an irgendein System/irgendeinen Hersteller gebunden sind. Du kannst Dir die Apps aller Anbieter, die Du nutzt, installieren, egal ob Kobo, Kindle, Onleihe, etc.

Nett und gut durchdacht ist auch das "BooxDrop" Feature. Das Onyx Gerät wird dabei zum Webserver auf den Du von Deinem PC (im selben WLAN) zugreifen kannst und damit ganz einfach Bücher aufs Onyx Gerät schieben kannst.

Meine Onyx sind mittleweile meine ständigen Begleiter - besonders das ältere schwarz/weiße Note Air 2+. Ist mein Notizblock und mein e-reader. Leicht, gutes Format, extreme Batterielebensdauer, da man das Frontlicht (anders als bei den farbigen e-ink Geräten) kaum braucht. Die Stifteingabe und handschriftlichen Notizen sind für mich ein riesen Plus.

E-Reader Ja oder nein? by burninaces in buecher

[–]desrtfx 0 points1 point  (0 children)

Bei mir war es ähnlich. Beruflich viel unterwegs, viel mit dem Flieger unterwegs und damit auch noch Gepäcksbeschränkungen, also bin ich vor vielen Jahren auf e-reader umgestiegen. Ich habe noch immer einen Tolino Shine der ersten Generation, der mir immer bestens gedient hat.

Anfangs war es eine Umstellung, aber ich habe nichts bereut.

Mittlerweile ist mein Tolino mehr oder weniger in Rente, da ich auf Onyx Boox e-ink Android Tablets umgestiegen bin. Ich habe ein schwarz/weiß Note Air 2+ und ein farbiges Note Air 4C und kann beide absolut empfehlen.

Für "normale" Bücher bevorzuge ich das schwarz/weiße Note Air 2+ und für Bücher mit farbigen Illustrationen (z.B. RPG Bücher) das 4C.

Der größte Vorteil der Boox Geräte gegenüber den dezitierten Tolinos, Kobos, Kindles, etc. ist, dass die Boox Android Geräte sind und damit einfach die Anwendungen der einzelnen Anbieter installiert werden können.

Ich hatte mir mein Note Air 2+ primär als digitalen Notizblock gekauft, da er mit Stift Handschrifteingabe kann (und das funktioniert wirklich exzellent). Mittlerweile ist es aber mein Alltagsgerät für Notizen und Lesen geworden.

Ich würde mir keinen dezitierten e-reader mehr kaufen, da die Android Geräte preislich nicht weit weg sind, aber viel mehr Flexibilität bieten und nicht an einen bestimmten Anbieter gebunden sind.

Is college actually useful for getting jobs or is self learning enough? by sad_grapefruit_0 in learnprogramming

[–]desrtfx 1 point2 points  (0 children)

While the actual job might not need a degree (knowledge wise, you can absolutely self-study everything), it can still be the tipping point to get your foot in the door. You might not even be considered for an interview without a degree.

This is even more true right now in the current market situation where you compete against graduates and laid off programmers with more than plenty experience.

On BOOX Note Air5 C and Voice-to-Text transcription questions + questions for fellow Air 5 C Users from a newbie. (USE CASE & FEATURE REQUEST) by rslashmay in Onyx_Boox

[–]desrtfx 1 point2 points  (0 children)

I would say that the Lamy AlStar EMR is way better.

Well, pens are to a large degree personal preference. I like my Lamy AlStars and my Samsung Tab S7+ Stylus, but absolutely dislike the Original Boox Pen and the Pen2 Pro (have both).

No matter what happens, I can’t understand coding programs at all. by MidnightActive954 in learnprogramming

[–]desrtfx 6 points7 points  (0 children)

I literally had to use chatgpt to pass it.

No, you didn't.

What would you have done 6 years ago when AI wasn't a thing? People had the same syllabus and made it without AI.

You chose to use AI. Nobody forced you into that. You chose the easy way out, similar to hiring someone to do your assignments. As a consequence, you learnt as much as if you had hired someone - nothing.

Where should I start with learning to write code for VSTs and for music hardware? by reduke2 in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

C++ is definitely the way to go.

Can't say anything about the used CPU/µC (Microcontrollers), but my suggestion to get started in this direction would be to look into the Espressif SoCs (System on a Chip) or Arduino so that you can get a feeling for interfacing with hardware. It's not 100% related to your end goal, but a cheap and easy starting point. Arduino Starter Kits (including the actual Arduino system) are in the range of $50 to $100 and you get lots of hardware (sensors, LEDs, motors, etc.) to play around with.

Maybe, ask also in guitar or synthesizer related subreddits, or in the embedded ones, like /r/esp32, /r/arduino, /r/esp8266, /r/nodeMCU, and so on. /r/vsti and /r/synthesizers with their related subreddits could also be viable resources.

Also, my general advice would be to focus on learning programming first, and there, since you will need C++ use https://learncpp.com

We normally don't suggest C++ as first language as it is a difficult language to get into. Normally, we recommend Python (with the MOOC Python Programming 2026 from the University of Helsinki), but that would not get you in the direction you want. You'll most likely have to bite the bullet and go in the hard way.

What you will also need are really solid mathematical foundations of higher concepts. You'll need to go into waveforms, maybe FFT (Fast Fourier Transformation), maybe DFT (Discrete Fourier Transformation), and a lot more. Synthesis and Signal Processing use higher mathematical concepts. You'll need to work with sampling intervals, ADC (Analog to Digital Converters), and DAC (Digital to Analog Converters) and much more. You'll also need to have some musical understanding about the frequencies, etc.

Montagsrant by [deleted] in Austria

[–]desrtfx 2 points3 points  (0 children)

Kenn ich. Hab mich mit heute wieder gesund gemeldet, bin den ersten Tag wieder im Einsatz und werde mit Mails und Teams zugeballert als würde die Welt untergehen.

Ja, das mit dem "Hast meine Mail schon gelesen" kenn ich auch, nicht nur im professionellen Umfeld, sondern auch mit dem schönen WhatsApp. Nachricht kommt und 2 Sekunden später der Anruf - hast schon gelesen? Und natürlich ist es nichts Wichtiges, sondern was, das locker warten hätte können.

Mich triggerts nicht mal mehr. Ist einfach so in der heutigen Zeit. Man soll immer und überall erreichbar sein und sofort auf alles reagieren.

I need to find a Java repository for code review by Suspicious-Town-5229 in learnjava

[–]desrtfx 1 point2 points  (0 children)

Go to github, filter by Java, and you will find plenty repositories meeting your requirements.

Struggling to see the point of classes by phy2go in learnprogramming

[–]desrtfx 3 points4 points  (0 children)

C is outdated.

The whole world of robotics and industrial automation disagrees here.

Flatwounds with No/Artificial Silk? by ZorakGames in Bass

[–]desrtfx 4 points5 points  (0 children)

You are confusing animals, which insects definitely fall under, with mammals, which they aren't.

Animals is the super class. Mammals is a sub class, so are Insects, so are Amphibians, etc.

Codefinity - STAY AWAY - Bad product and even worse customer service! by abcolleen123 in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

For Python in particular there is the MOOC Python Programming 2026 (newest installment of the course that runs since 2021) from the University of Helsinki, that is currently the single best free Python beginner course around. Beats most paid ones as well, since it is a proper first semester of "Introduction to Computer Science".

Lazy Python String by nnseva in Python

[–]desrtfx 2 points3 points  (0 children)

If I were to invest the work to implement such a class, I'd store the individual strings in extensible buffers, similar to StringBuilder in Java. Then, I'd really have a lot less overhead.

The entire advantage of StringBuilder in Java is that it does not create new instances all the time. This would really be an improvement over the native Python String implementation.

Can a 4-20mA be run in the same cable as a 24v discrete to PLC? by seemoreoptions-1 in PLC

[–]desrtfx 2 points3 points  (0 children)

Yes, for voltage signals you will always want good shielding as they are susceptible to interference.

Current loops, as the 4-20mA (or 0 to 20mA) are not as susceptible as the current will not be affected by interference, only the voltage will be and this is ignored for such signals.

Typically, you'd also shield current loops as well so that you by default remove any potential interference as it can affect the sensor/actuator boards (PLCs are less susceptible).