#Need help with 2D Array
1 messages · Page 2 of 1
thing is, there is no list of questions u have to pass on an interview. there are no points u get, like in an exam
its a gut feeling
they ask u questions, supposedly on the whole range of possible topics
just to get an idea of ur knowledge spectrum
and then they decide based on gut feeling "do we think that this person would be able to do the job?"
I've actually also been working on my CCNA so that's gonna take a lot of my time, don't know how much I'll be able to code Java haha
Which btw, in your professional opinion
What do you think of CCNA?
so if i ask in an interview whether u know what a class is or what the private keyword means, and u cant tell that, then its clear to me that u never really wrote any java at all (besides maybe 5 minutes hello world)
I think everyone knows what a class is KEKW
but if i ask "explain the diff between arraylist and linkedlist" and u cant tell it, thats not a huge bummer. that just means that u never explored the insides of data structures
u would be surprised what sort of people i interviewed already LOL
Yeah true I dont care much for linked list tbh I think linked list sucks
It's trash
Why tf would I ever use a linked list
yeah so if u would apply to a job where u would have to create ur own data structures / algos, i would reject u then
but if thats not the case, i wouldnt care too much
cause its just not required
Hahaha
That's funny
but if u would know it, it would add a little plus on my gut feeling that u probably have some experience and are not just a kid who just started coding yesterday
so at the end of the day it just adds to the picture/impression people get of u, when they interview u
if u apply to a spring based backend job, it would be helpful if u know what spring is and what a database is
but for a junior i wouldnt expect too much of knowledge here
i would expect a solid java foundation and then maybe a "yeah, i explored spring for 2 weeks and i think im able to understand the code with some assistance"
the "solid foundation", people get while doing their 2-3 years studies
Does it help that I've done JDBC and PHP with Mysql in the past but don't remember much? 💀
or by self-learning/practicing for a similar amount of time
sure. at least u know what its about and have some understanding
if i show u some basic sql, u wouldnt be lost
SELECT name FROM persons WHERE age > 25
see. so thats already more than majority of beginners know
sounds to me like ur not a beginner but actually have relevant project experience
or at least sth in between
Like it's just stuff you learn at uni 
But you tend to forget
Like which is bad
Obviously
I hate that like...I tend to forget stuff, everyone does if you don't review it every other day
yeah but it sticks in ur head actually and u can re acquire the full knowledge on demand much much faster
Yeah it's ez to go back and review stuff and instantly understand it sure
But when you ask me on the spot
I might fumble
You know what I mean?
the good thing about uni is that a degree is essentially, by definition, "having passed the minimum junior requirements"
AnD that would make them think I don't know it
since the uni takes care to teach all the necessary stuff
so for all the students, its fairly easy to get a job. cause they all passed the minimum requirements already
maybe add a few side projects on top, so that the CV isnt empty and then ur good to go
for people who self-study, its a bit harder, since they have to find the road themselves
and spend equivalent time and effort into learning
but its doable and at the end of the day, at least for programming, nobody cares how u got that knowledge - as long as u have it
yeah but thats okay. thats why u prepare a bit for an interview and if u still get asked sth u dont know ad-hoc, u can always tell them that uve done this in the past and would need a quick refresher first
also a reason why i dont mind language switchers too much
like, ive had people in java interviews who had 10 years of exp in another language and just learned java for 2 weeks before the interview
and then they do simple mistakes
like syntax stuff or not knowing the name of a class in java, but knowing it in the other language
that just means that they have to google a bit and need more hands on experience. not really an issue in practice
Oh yeah and isn't the actual Job different anyway
Like the actual job has a different kind of coding
You need to learn how to work with the existing company project
Which is completely different usually from whatever you know
yeah. but thats why i usually concentrate on asking stuff somewhat related to the job
like, right now im working as a backend dev on a spring rest api for a webshop
That's pretty cool
then it would be really cool if someone has actually made a small demo spring webshop project and put that on their CV
that would be a huge plus
You're a Senior developer I'm assuming
by now, yeah
Maybe I could work on that actually
And you can help me if you don't mind?
I don't know what spring is but still
I haven't done a lot of projects so
I probably should do some
sure. but for a junior i really wouldnt expect more than just following along some simple tutorial
a junior needs a solid java foundation, thats all
the rest is just bonus
with the intermediate developer, i would focus more on code style questions
Oh okay and I wanted to ask about APIs in particular
like showing them a piece of badly written code and asking for all flaws
How do APIs actually work
cause the intermediate not only needs the java foundation, but also the library/framework experience + okayish code style
Oh yeah I have no idea aside from like some Time Complexity and even that, I didn't really understand until you explained it to me 
yeah dont worry. thats the kind of stuff u care about after u feel comfortable with all the coding already
as in "okay im bored. how can i write code better now? so that its more readable and understandable"
which directly leads into all the patterns that u can find online
such as proxy pattern, builder pattern, whatever ....
Yeah I'm not there yet lmao, If I can find the solution to a problem, I'm happy-
exactly. and thats really all thats required for a junior
I don't care if it's having a Time complexity of O(n^1000)
note that in practice its usually more relevant if ur code is readable, than having good performance
since performance rarely is a factor ever
computers are really powerful, even the bad ones
so its about good variable naming, introducing more helper methods, having a good layout of classes, ...
I see, well our professor made it seem like Timw and Space complexity, but more so time complexity was a big deal
but thats only really relevant once u create projects with more than 10 classes
id say its important mostly in research/academics and for very specialized things
usually, in each project there is like one tiny spot that is supposed to be fast
but the remaining 99% dont really matter at all
like, who cares if u sort a list of 100 elements in a shitty way if the difference to the fast way is just 2 nanoseconds
Ohh I see
meanwhile ur reading a file and it takes 1000 the time
so "mistakes" dont matter in 99% of ur code
Most code that I've seen is just full of stuff thats already present
Like you're just using the different methods of the class already implemented by someone
yeah and thats a beauty of java. u rarely have to reinvent the wheel
everything exists already
Yeah that's why I'm starting to prefer Java a lot more
It's just very convenient
I wasn't liking it last semester but I then I got an A in it
and I thought...You know what, maybe this is actually fun
ive been in a c++ job with a "no libraries" policy and we wanted to make a simple http request to a rest api. it took us about 6 months to write the code for that
meanwhile in java its 2 lines of code...
ill never forget that
No libraries policy??
What
Can't they just audit the library if they're so scared??
the main reason was that the company did not want to be dependent on someone else
as in, imagine that they introduce a bug or go down or stop supporting a new c++ version or ...
that could potentially ruin the whole business
in theory
but then again... letting 4 developers work for 6 months on this bullshit, probably spending 2 million worth of salary...
that calculation just doesnt work out lol
And what if you guys couldn't come up with it
Cause some stuff is genuinely extremely hard without libraries
That's kinda dumb, libraries exist for a reason
Wtf
yeah. so with c++ we had to start at the lowest level. for making our rest api call, we first needed to implement TCP with the windows socket API, then build HTTP on that TCP layer, introduce SSL encryption for HTTPS and then build REST on top of that ...
and we obviously only implemented like 30% of the full standard
cause the full standard is like crazy complex
and we hunted and fixed bugs for a few months lol
Socket programming? Wtff
and all of that just bc c++, in contrast to java, has no http stuff build-in
at least not without library
C++ has it, you have to import the http library or I forgot it's name
well, i learned a lot about tcp/http/... but business-wise it was kinda stupid ngl
yeah. there are a lot of great libraries for doing that stuff
and i dont know any serious c++ project who isnt using at least the boost library
but heck, we didnt
Tcp is a layer 4 protocol which encapsulates data at Layer 5 which is Session Layer with a TCP header or a Layer 4 Header, also called a Segment, which then goes to Layer 3 and then an IPv4 header is added and then it's further encapsulated into an Ethernet frame at Layer 2 in which a Layer 2 trailer and a header is added which also checks for errors in the Physical Layer in its trailer using Cyclic redundancy check in its FCS or frame check sequence
Then it's de encapsulated when it is pushed up the other computers OSI stack or TCP/IP suite
yeah its just the thing on which HTTP is build on top of
And you're telling me you implemented all that with code that's crazy
I mean you implemented TCP atleast
windows offers TCP sockets, which takes away most of the work
but still lot to do unfortunately
I've done Network programming in my 3rd semester, I hated it 
It's so pointless
There's not much of a point to it
Also the CCNA is very good for learning networks, I feel like I am developing an understanding of Networking that I never had while studying for the exam
I highly recommend it
For anyone interested in Networking
Also I wanted to ask about REST APIs
Correct me if I'm wrong but REST APIs are used by different applications to communicate with each other right? The applications that have a different format and such
Say I wanted to get some hands on experience with REST APIs
How would I go about doing that
Like I want to understand what exactly it is
It's very popular and everywhere pretty much
first of all, it helps to understand that computers can talk to each other via "internet"
Yes but we're talking about Applications here right
but an application runs on a computer
u can send arbitrary bytes to computers
the protocol that takes care that those bytes also arrive correctly (and it proper order) is the IP
(internet protocol)
now, build on top of that are two extra protocols that are mostly in regards to fault tolerance and order
TCP and UDP
TCP for example sends some packages as copies and over different routes, to ensure that the data arrives
so far it was just about "how to send the data", but not about how the data itself should look like
so u can now send arbitrary data around
Yess fun fact, the order is determined by the Fragment Offset field in the IPv4 header if the packet is fragmented and the fragments are identified by the Identification field!!
now, people created a standard for how the data should look like when u do stuff on the web
called HTTP
http is a human readable format, as the data u send is just UTF-8 encoded text
Yeah but HTTP is unsecure
yeah but with HTTPS its just HTTP encrypted
Data isn't encrypted so uts not advisable to use Port 80
so after decrypting, its still human readable
Instead you must use 443
point is, its easy to use, cause u can read it
so if u for example open ur developer tools in ur browser (F12), u can see the whole traffic and read it
easy to work with
so thats HTTP
now, people build another layer on top of HTTP
I mean if you're developing the app then yeah
For that purpose, but when you actually release it, you'd probably release it in HTTPS I guess?
So it's a Layer build on top of HTTP then
for example, when there is a rest server online that saves persons (maybe in a database), then REST would say "if u want to delete one of those persons, then u should send a HTTP DELETE request to thatWebsite/persons/123 with maybe the ID of the person
or
"if u want to edit the person, send a HTTP UPDATE request to thatWebsite/persons/123 and in the body, have the new data"
Hold on, wouldn't that be the job of your Delete.php code?
no. thats the thing
Or update.php
in the past, before REST, people came up with their own ideas of how to work with the data
what ur mentioning is one of such self creations
but people wanted to standardize that
after a few years of pain
so they invented REST
Well I've personally made these update.php, delete.php pages and done it for a website 
So that's why I'm confused
yeah sure. thats just how it was done before REST
there was no actual standard. people did what they thought was reasonable
everyone came up with sth else
using HTTP the way they thought it would make sense
Oh now I understand...so it's a standardized way of...interacting with an application
nah, it just describes how to do the user interface
It processes requests
everything else u have to code urself
like, it says "if u want to offer persons, instead of coming up with ur own ideas, please do the following:
- for creating new persons:
HTTP CREATE website/personsbody=person data, as json - for deleting a person:
HTTP DELETE website/persons/123no body - for editing a person:
HTTP UPDATE website/persons/123body = new data
...
and it also talks about the return codes ur supposed to send
200 OK, 202 CREATED, ...
and whatever
and REST is also supposed to be "stateless"
Those are standard HTTP Server side/client side codes though
Like 200, 203, 403
You'd be having those anyway
that means, if u want to create a person, instead of offering maybe a 2 stage process where one first has to call HTTP GET website/person/getId.php and then HTTP PUT website/person/create.php?id=123, ur supposed to offer one single endpoint that does everything
so that u dont have to remember a state
yes. but if u design it urself, maybe u come up with some non standard stuff
REST tells u to follow the standard
for example, REST says to use 204 NO CONTENT when u update a person
since ur not supposed to send back a response body
instead of using 200
🤷♂️
anyways. its really just to have one standard way of doing these apis
I don't really get the meaning of stateless
Like I know the meaning of stateless in the context of a firewall
But here, I don't really get it
mh. suppose ur at mcdonalds and want to order at one of those order machines
u click 5 buttons, building ur basket
right?
then u pause and go to the restroom
Yes
now in the meantime
what if someone else goes to the machine
its still in ur order-process
not yet done
REST wants to avoid that. REST wants u to have a single interaction
u dont clicky click 20 times
u click one time only
imagine having written down ur full order and everything on a paper beforehand
and letting the machine scan it once
and imemdiately order
It would wait until my order is processed and then begin their order?
cause everything is there on the paper already
its about the interaction
is the interaction a single "here is everything u need. now go and do it"
or is it a
"first step : ... okay, now second step: ..., third step: ..."
if u want to create a new person, do u do one single http call or do u have to do 5 calls?
Just one call I'd imagine
if u want to delete a person, do u do one single http call or do u have to move around 2 websites and submit that one form and with the result of that call another website and ...
and thats what REST wants u to do, yes
it wants to avoid that u create complex processes that require multiple calls
i.e. maintaining a state or session of the interaction
in particular, the order shouldnt mention
lets say:
So REST is like this?
yes
but also order, as just shown
deleteLastOrder depends on the current interaction state
if u call it twice, it changes its meaning
How is that possible, the user has to enter the ID first in the Input field and then it'd go to the uh $variable = $_GET[];
thats just how PHP implemented forms. HTTP has nothing to do with websites technically
And then you can work with it there and it'd appear in the delete.php?orderID= user has entered here
also, i was just giving an example
forms are just an invention of people who created browsers. HTTP doesnt know any of that, it doesnt care
Forms are the main way you carry input over to your backend page though, be it Node.js, PHP, whatever right
if u think about actual websites where users click around, yes
It's like how you do it
but most apis are not used by frontends
I haven't worked with an API at all, like I have no experience with them
And I'd like to get some tbh because it's hard to understand exactly what you're telling me haha
yeah sure. i think it helps to demystify http by writing ur own socket based http server in java once. at least a super bare bones
its surprisingly easy
yes. but i mean really just a java program that, when u run it and someone (like ur browser) connects to it, sends some hello world website
so that u can open in ur browser localhost:8080 and it shows ur own example website
served by ur java code
at which point u can see in java how ur browser talks to it
and how HTTP works
Well..Yeah I mean
Did they teach us another Legacy thing and leave it behind
That's unbelievable
Quite infuriating
essentially, everything web related in java got replaced by spring about 20 years ago
or well, id say it took a bit to actually replace but u wouldnt see any non spring stuff since 10 years anymore
Spring wasn't even mentioned in the CSE1007 Java Programming 4 credit course I did
unless in some legacy projects
spring essentially lets u write a full rest api, with database and everything in just 10 lines of code or so
and it has a solution for everything
It was JDBC, Java FX which sucked, JSPs, OOPS, Java applications all that stuff
like, imagine u want to add google based user login to ur code
sounds complex but spring got u covered with just 2 lines of code or so
its the standard for backend stuff
That's...so simple
but therefore its also quite big and complex
and it uses a lot of advanced java stuff
it feels like black magic to a lot of beginners
in particular to everyone new to dependency injection
Just how recursion felt to me
yeah
its definitely not sth to slap a beginner in the face
but its definitely the standard used in majority of java based jobs
I'll look into Spring, if it's just 2 lines of code for stuff like that, it's worth looking into
What would you recommend, like how to start working with APIs a little and get some experience with them and what they are
Which Applications API to sort of start and tamper with, just to see how it works
theres this:
which is like the example rest api everyone works with for trying out stuff
ucan see some examples here https://jsonapi.org/examples/
Oh yeah...I know Json is used for configurations and like making data travel I guess
But I've never used JSON
its just the standard way of representing data in readable text nowadays
technically for REST it doesnt matter though
And Idk what it actually is, I've configured JSON in like VS Code I guess
its just a way of representing ur data in a readable way
Okay but why though, why would I need JSON
spring supports automatic conversion of java objects to json and vice versa
how would u send a java object around the wire?
lets say Person p = new Person("John", 20)
now u gotta send this from A to B
so what do u send
u can come up with ur own thing now
for example maybe
Probably the .java file itself lol
Person object[name=John;age=20]
but thats the source code
not the actual object
You can just like send a class that inherits that object I guess
You'd be able to use the object though
okay, another example
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a name:");
String name = scanner.nextLine();
System.out.println("Enter an age:");
int age = scanner.nextInt();
Person p = new Person(name, age);
// send that person to our api
api.createPerson(p);
now, how would createPerson work?
its supposed to send this person data to the rest api
u can now come up with ur own shit
for example
Is api a class that this class inherits or implements or something? What is api.
okay. let me put it that way:
Socket api = new Socket("http://myWebsite/createPerson");
api.writeBytes(...);
now, how do u transmit ur person data to that server?
u can only write bytes
u got ur p java object. and now?
there is no "java object to bytes" thing
u have to come up with something now
another example. suppose ur java program can write emails
and now u want to send this person object "via mail"
mail.writeMessage(...);
what to put there? it wants a String from u
so now u need to figure out how to make ur Person a proper string
in a way that the person reading the email can read it
and potentially put it back into an object of their language of choice
maybe c++
so. now u can come up with ur own crazy ideas/formats/standards
but u have to write toString, otherwise it ends up as Person@A13DF5 only
so what do u write in toString
should it be John, 20 years old
or
Person[John, 20]
or
John=20
or daskdqwke132keq23keawskdaksdJohn----20----LOOOOL
I mean you can use .join
ur not getting the point
String.join("", str)
Oh okay
it should be sth that is:
- readable by a human
- easy to work with from code
I see what you mean on reading through it
lets say u send it as John,20
return name + "," + age;
now, the receiver could write simple code like:
String message = mail.receive();
String[] data = message.split(",");
Person p = new Person(data[0], Integer.parseInt(data[1]);
to receive back an object in their favorite language
okay so far?
Okay you are not splitting the mail with a " " that's my only problem but yes I'm good 😆
i used , not space
but oaky, we can also go with space
then the toString will be name + " " + age;
and we can split on space then on receiver side
Yess that's just what I like, just add space to everything like normal, like you would in a sentence and it's easy to split a string then you know
now, we created our own protocol for sending AND receiving a person object via mail, by temporarily transforming it into text - following some pattern we just invented (data separated by spaces)
and that works perfectly fine
until...
what if the name contains a space?
Yes that would be an issue
if sth contains a space, we add quotation marks around it, to indicate start and end
resulting in
"John Smith" 20
the receiver side is more complex now
but it can be done
next problem
what if the name contains a quotation mark?
solution:
it must be escaped, lets say by writing two
""
resulting in
"John Smi""th" 20
congrats. u just invented whats called CSV
You're gonna give up at some point I believe, the name could have anything like ^*&%$'
The....excel file format..? Uh?
usually its used with comma or semicolon, but technically it doesnt matter what the delimiter is
yes
now, next issue
what if u have nested objects
like, lets say john has a pet
What does the excel file format have to do with escaping a string though
Oh I see and it's always in a table?
csv has nothing to do with excel
A big table with 2 or more columns
its just that excel tables naturally make sense to be represented as csv
I didn't know that, I thought Csv was an excel file format that's all
🙂
so, csv is not good for representing nested data
which we will see next
List<Animal> pets = List.of(new Dog("Bob"), new Cat("Jane"));
Person p = new Person("John", 20, pets);
how to represent that with text now
in a way that we can understand what it is
now it gets complicated
so. u can come up with ur own ideas now again
We have a list now right
yes
and the list can contain different types
we have to know the types on the other side
We could just...convert the List to a String again and then it's just another John
so do u want this?
John 20 Bob Jane
but then, how do we know on the receiver side who is a dog and who a cat
or are both cats?
or a fish maybe?
We could send them a reference like....The text sent to you after the age, rhe first one with an ID of 1 is a dog and the Id of 2 is a cat
So we could attach a code or a number along with the Bob and Jane
yes
okay, next problem
what if dogs can optionally contain a birth-name
like before they got renamed
What would that even look like
And now you want to change it?
John 20 Bob Karl Jane
but now we cant differentiate anymore if its 3 animals or 2 animals where one had an original name
so we need to start to introduce certain "start and end" markers
for example
John 20 (Bob Karl) Jane
Karl would again get a code of O1 indicating that O means original and 1 means dog that is Bob and to ensure it relates to Bob , we can have an arrow pointing to Karl I guess from Bob
okay. im sure i would find more issues with that
anyways
long story short, at the end of the day, after fixing all "issues", u end up with JSON
1Bob -> OKarl or whatever
or similar protocols like XML
Okay and?
so JSON, XML and friends are standardized text formats that solve all those issues
so instead of inventing ur own thing
u can just use those
How though
{
"type": "Person"
"name": "John",
"age": 20
"pets": [
{
"type": "Dog"
"name": "Bob",
"originalName": "Karl"
},
{
"type": "Cat",
"name": "Jane"
}
]
}
or in xml:
<person>
<name>John</name>
<age>20</age>
<pets>
<dog>
<name>Bob</name>
<originalName>Karl</originalName>
</dog>
<cat>
<name>Jane</name>
</cat>
</pets>
</person>
Hey you know, maybe you should archive this channel hahaha, so I can keep coming back to read stuff if I have doubts again regarding any of this
haha 😄 u can /bookmark it
This is a great explanation honestly
ur welcome
It is crazy how I am now able to really understand the meaning
so yeah. the advantage of using JSON or XML instead of ur own thing (which technically would work fine as well) is not only that u dont have to solve all those problems anymore, but u also dont have to write code to make ur object to text and text back to object anymore
u can just use a library like Jackson
and do
String json = jackson.write(p);
and
Person p = jackson.read(json, Person.class);
We've all heard of this stuff like Json and even see it but never used it or never really been properly explained
Oh that's so neat
Jackson would jsut create a separate JSON file I'm guessing
Once you run the program
@Update
public User editUser(String id, User newData) {
userDatabase.update(id, newData);
return newData;
}
and spring will automatically transform everything for u
it works with any database
MongoDB
being the industry standard, it supports them all
the main point here is that it magically transforms above method into a http endpoint
like, with above method, u now can call
HTTP UPDATE website/editUser?id=123
{
"name": "John",
"age": 20
}
sending that body
as json
and it will automatically understand everything and do it
and return back json again
by auto transforming the object to json
To the database or to like the websites front-end?
to the frontend who called it
even though most apis are not meant to be consumed by websites directly, ur browser is actually capable of viewing json nicely as well
like, look at this example rest api call
which returns json
and ur browser should display it nicely browsable
Yup it does
How'd you manage to host a dummy website so quickly?
What the hell
its not mine. thats an example website
but i indeed can spin up sth really quickly, since i have setup a free DNS record to my machine
Don't you need to port forward it to host it
Nvm you said DNS
It's not a server I just realized
it is
and it has a port
if u dont write any port explicitly, it implicitly uses port 80
Yeah but it doesn't need to be forwarded does it?
For you to host it on the WWW
When you start your own server in like a Linux machine
You need to forward that port in order to host your files on the WWW, files that you want to serve to someone maybe on the other side of the world
u always have to do port forwarding
IP addresses point to ur router, not to a pc
so u have to tell the router to which machine in its network it should forward the traffic to
like, maybe traffic on port 80 is supposed to go to ur computer
and traffic on port 1000 to ur sisters computer
and on port 1020 it should be forwarded to ur mobile phone
thats what port forwarding means
DNS is a service that points a name to a ip address. thats all
for example my current ip is 37.201.34.222
so u could now type in ur browser 37.201.34.222:80 and it would connect to whatever is currently setup on my router to listen to port 80
(which is nothing)
but since nobody can remember numbers, u can setup a DNS entry
and associate a name with that IP
for example duckdns provides that for free
resulting in pitaya.duckdns.org to be the same as above IP
Yes but I think that in WiFi networks and real network topologies, that is done automatically, you don't need to do it right? Or you do?
u do have to do it always
imagine ur living in a house that has 5 appartments but only one box for letters
and people dont write the names on the letters
but just "to this house"
nobody would know which letter is for whom
port forwarding is the process of putting names on the letters
So you can say that for port x you can forward the traffic to 0.0.0.0/0 basically create a default route to the internet
Forward it through whatever interface/port you need it to forward out of
huh?
if someone comes with traffic to ur router, "hey there, i have a request, port 80"
ur router has to decide to which of the 10 machines in ur home network to put that traffic to
so u go into ur router settings and tell it
"hey router, any incoming traffic to port 80, please move that to the my computer. traffic for port 1000 please to my sisters computer and traffic to port 2000 to my mobile phone, thanks"
I mean if all the devices are connected to the router and if traffic comes that is intended for a particular device, the router would know which device to forward the traffic to, it would be the device requesting it as it's Destination IP address would probably be listed on the packets coming for them
It's on the IPV4 header, the destination and source IP address
That is how it's been explained to me
the IPs point to routers though
not to individual machines
the IP of ur machine, the machine of ur sister and ur mobile are all the same, since its the IP of ur router
u dont have individual IPs
at least to outsiders
the router also uses its own independent IP subnet for giving out local addresses for managing its own connected devices
but those IPs are not exposed to anyone other than the router itself
hence they are called local IP
and usually always look like 192.168.0.xxx
Yes but the packets are usually addressed to the Internet IP of the device rather than rhe local IP and the router knows both the local IP as well as the internet IP of the devices
Apparently
I'm not too familiar with WiFi as of yet, cant say for sure
Closed the thread due to inactivity.
If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you 👍
heyy Zabuzard @meager hollow
whats going on??
had a question I wanted to ask you, its a bit of a weird one
import java.io.*;
public class My_project {
public static void main(String[] args) {
String inputFile = "test.txt";
String outputFile = "output.txt";
try {
FileReader fileReader = new FileReader(inputFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
FileWriter fileWriter = new FileWriter(outputFile);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
String line;
while ((line = bufferedReader.readLine()) != null) {
line = line.replaceAll("\\b\\d{1,2}:\\d{2}\\b", "");
bufferedWriter.write(line);
bufferedWriter.newLine();
}
bufferedReader.close();
bufferedWriter.close();
fileReader.close();
fileWriter.close();
System.out.println("Timestamps removed and output written to " + outputFile);
} catch (IOException e) {
e.printStackTrace();
}
}
}
So I was watching Youtube videos and learning and copying some of the transcript content in my notes
but the issue I was having was the timestamps and I really wanted to remove them
so I thought I'd write a program in Java to solve my problem for me
But the issue is, its not quite how I want it to be
The output text is something like this
it does remove the timestamps but
but I dont want the lines to come out like that with like a space in between
For example, in this network traffic from PC1 to PC2 usually follows this path.
But what if this connection is cut off? This switch will think: I can’t reach this neighbor anymore.
I’ll clear all entries for this interface from my MAC table, and its other interface will
become the root port. Then, if PC1 wants to send traffic to PC2 again, it will go through the normal process
of flooding until it learns the MAC address on this new interface, and traffic will now follow this path.
That’s just a quick look at how topology changes are handled in rapid STP.
This would be the desired output
Not sure how I can achieve this
get rid of the br.newLine()
btw, u should use NIO and not this 20 years old way of doing file io
File IO in Java should be done preferably with NIO (Java 7+), revolving around the classes Files and Path; and not with the old interface File, BufferedReader, FileReader and similar.
NIO is simple to use. The path to a file is represented using the Path class:
Path path = Path.of("myFile.txt");
All file operations can be found in the Files class:
// Reading
List<String> allLines = Files.readAllLines(path);
// or as a single string
String content = Files.readString(path);
// or with a stream
try (Stream<String> stream = Files.lines(path)) {
stream.forEach(System.out::println);
}
// Writing
Files.write(path, lines);
// or as a single string
Files.writeString(path, "hello world");
// or with extra options
Files.writeString(path, "hello world",
StandardOpenOption.WRITE,
StandardOpenOption.CREATE,
StandardOpenOption.APPEND);
If you need more control over the process, you can fallback to the old interface, but prefer using the bridge methods from NIO (Files.newBufferedReader, Files.newInputStream, path.toFile() and similar) to benefit from advantages such as correct encoding and better error detection.
Here is a simple example of how to read a file line-wise with the old interface
try (BufferedReader br = Files.newBufferedReader(path)) {
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
it is way more verbose than NIO but it gives more control.
You must not forget to close file handles, even in all exceptional cases. Closing a handle manually is very hard, which is why you should always use try-with-resources for this to let Java automatically close the handle for you:
try (SomeResource resource = ...) {
...
} // Automatically closed here, even in exceptional cases
what is that
a much easier way to do file io
ohh I gotta learn that then
So that wasn't the desired output
yeah Idk how you can achieve that really