Please don’t buy anything from this person. Anything they teach, you can learn for free from better resources. They want to scam you off your money under the guise of “I love teaching and sharing knowledge with people”. They’re using a fake account now because their old one was banned in many subreddits for spamming their “amazing” offers.
P.S. This course has a lecture on git. Alternatively, read this comprehensive and not at all difficult to read documentation book.
Your choices are really IntelliJ, Eclipse, and Netbeans.
I would recommend IntelliJ. There is a free Community Edition if you want to try it out. https://www.jetbrains.com/idea/download/
There are people that swear by Eclipse and there are even people that swear by Netbeans. You can try them all out and decide which one you like best.
If your ultimate goal is to develop for Android, you should use IntelliJ Community Edition.
The reason for this is that Android Studio is built upon IntelliJ and thus you will already be familiar with the IDE when you make the move to Android development.
> Also, what is the difference between LibGDX, Unity, and Android Studio?
Synchronously logging to an HTTP endpoint sounds like a horrible idea. For this kind of thing best to use a long-lived connection. You definitely don't want your app to do this.
Best to use something like logstash:
https://www.elastic.co/guide/en/logstash/current/plugins-outputs-http.html
Is a SOAP service your only option? Is your system living in the dark ages?
Such static
methods to create new instances are called static factory methods. They have some clear advantages over constructors, but using them everywhere would be too convoluted and they also have some restrictions.
Basically, having no public
or protected
constructor means that you can't extend the class, so if the class is supposed to be extended it's not appropriate. That's the main disadvantage of static factory methods, but it's pretty irrelevant if you don't plan to publish the code for others to use.
One significant advantage of static factory methods is that they're named, i.e. that they provide self-documenting code. If you have a lot of different constructor overloads, you might want to consider static factory methods instead so that you can differentiate them with their names instead of only relying on the exact constructor overload.
Another advantage is that static factory methods daon't actually need to create a new instance - they can return an already existing instance when appropriate. This finds use in singleton patterns and variations thereof.
A third advantage is that static factory methods can actually return subtypes of their return type. The EnumSet
class, for example, only provides static factory methods that return a RegularEnumSet
if the enum
type it is based on has at most 64 instances, or a JumboEnumSet
otherwise.
This answer is oriented on item 1 of Effective Java (2nd Edition).
UMLet should fit your needs as it is an Eclipse plugin.
ArgoUML as /u/Melair recommended is also a valid option, only it is standalone. It can do reverse engineering as well.
As a third option, you could import your code into BlueJ which is a "beginner IDE" that also draws UML diagrams and also creates the relationships of the classes for you. (I would not recommend using BlueJ as an IDE as such, because it is way too limited, especially once you already know Eclipse, but the UML feature is fairly nice.)
> but i wish somebody could respond me with a proper answer instead of just commenting about the lack of space or about how bad formated it is.
You do understand that it's you who needs help right? Don't you think it's a tad rude to tell people to not complain about stuff that you should be getting right?
Regarding your code: it's obviously not working. You got a Thing class and in some places you misspell it as Ting. Oh, and you seem to define class inside your main() method. That's not going to work at all. Methods go inside classes, not the other way around.
I don't really get how you got this fairly complex assignment without being able to do the most basic stuff. I would urge you to take a step back. Just writing a ton of stuff that doesn't come close to compiling isn't going to work; you're confusing the compiler so much that the errors it will give make no sense at all.
Get a very basic version that compiles and runs first. And make sure you separate classes into their corresponding .java files and use http://gist.github.com to post them separately instead of in one big unreadable mess.
Neither Eclipse, nor Netbeans are outdated IDEs. Both offer collapsible code and direct code navigation, just like IntelliJ.
Your statement about IDEs is just plain BS, despite your criticism being perfectly valid.
The comments indicate an outdated teacher who has never learnt proper commenting (nor read "Clean Code").
These comments are the typical comments taught in educational institutions by teachers who have done this for years and use this to have it easier to grade the homework.
If you have no idea, plug it into Ideone.
You will see the results immediately and it helps understanding the code.
What you see in line 6 is called the Ternary Operator
Even though your question was already answered by /u/Taylee:
People, please learn to google, learn to read the documentation, and try out the code.
Yes, you will mostly get a quick answer, but you will learn much more if you find/try things on your own.
Not strictly an array, but a list of characters that should be replaced. The square brackets indicate that whatever characters are between them should be replaced.
Look at the bottom explanation here: http://regex101.com/#aqr
I believe you're correct, and the solution is wrong. As you said, the first clause will be true (since the increment will be evaluated after the equality comparison), but the second will be false, since we first increment b, then compare it to 10.
You can even try it yourself: https://repl.it/repls/MarvelousAdmiredAxolotl
Lost is lost.
You have learnt a valuable lesson: save often and backup regularly.
That's exactly where source code version control kicks in. Learn and use git. It really helps you in any case. You can easily backup the source code (remote repository on gitlab, bitbucket, etc.) you can test changes and rollback if they don't work as you think, and so on.
It is fairly simple to get started with git and using it is just as simple. Here is a nice course (free, of course).
You have to use Android Studio. The UI is created using XML (or through pure Java code)
I don't believe there is such thing as Android Java.
There are however libraries made specifically for Android, for example Realm. You also have to learn some Android specific stuff such as not performing networking on the main thread.
The chronological progression goes AWT -> Swing -> JavaFX. Each one contains a number of elements from the former. JavaFX is supposed to be the future of GUI programming in Java, but there is still a lot of Swing code out there. Plus, many of the GUI designers are still geared towards Swing. JavaFX is a lot better for developing web-type applications, including animations and video.
Basically, either Swing or JavaFX will do fine. There are also some third-party GUI libraries out there, like IBM's SWT (which is what Eclipse uses), and libGDX which is geared more towards game programming and graphics intensive applications.
use spring boot.
https://auth0.com/blog/implementing-jwt-authentication-on-spring-boot/
this should be all you need to get up and running with jwt. really good guide, best one online. they try to upsell you to use their service for authentication at the end but it's not needed at all.
when you talk about manipulating database models as objects in java, what you want is JPA. that article uses it. if you look at the ApplicationUser class they make, it's annotated with @Entity. this will end up being an application_user table with the fields id/username/password. you can see them doing what you're talking about:
user.setPassword(bCryptPasswordEncoder.encode(user.getPassword())); applicationUserRepository.save(user);
they have an older guide here saying how to do it, but the first link in this post is a more up to date/better approach. if you want, you can look at this one just to see the differences or whatever. https://auth0.com/blog/securing-spring-boot-with-jwts/
You need to use a loop. I would recommend a while loop. So that while you're still playing, keep playing. You can use a boolean as the conditional for the loop and if they type in exit or quit or leave or w/e you change the boolean and the loop exits.
If read it correctly you use (and even modify) the community edition for commercial purposes: https://www.jetbrains.com/opensource/idea/#FAQ-Community Edition and https://www.jetbrains.com/idea/download/#section=windows (info under the "i" next to the community edition)
I wouldn't recommend spending money on any of the Oracle certified exams. I have never had anyone ask about Oracle certifications and I have never met anyone who has expressed they were glad for getting theirs. Use that money and buy some decent literature (Head First Java, Clean Code, Effective Java SE) and start coding. Make a github account and start posting anything you write. Go to a local Java Developers meet up and network. Honestly there are tons of things you can do to prepare yourself and begin to make yourself marketable for an entry level position.
For the love of god find someone else that teaches Java at a high school level. Go over their lesson plans with them. Figure out what types of things they are teaching through each unit. While reading Head First is a good introduction to programming Java, it isn't necessarily what you need to be teaching these kids at this point.
Is this a first programming class for most? Or is this a follow-up to an introductory class? There are a lot of variables that will influence the content and concepts that should be taught.
Finally, and please don't take offense to to this, but I find it crazy that they are having someone with NO experience in the position of introducing people to a field that can be simultaneously fun, frustrating, rewarding, difficult, etc. Again, please don't take offense, but you will not do a good job grading as you have no experience. You need time to practice identifying good and bad code yourself. For every problem out there you can probably devise hundreds of ways to successfully solve it, but only some of them will be elegant and (hopefully in a teacher's eyes) acceptable.
For the love of god take a programming class! Have someone look at code you are writing because there is no better way to learn than to do it yourself. Head Start is a decent point to learn Java. Also check out Clean Code as it will help you learn some fundamentals of what makes good code. Finally, get together with another teacher that has experience teaching this subject matter and leech as much as you can off of them. Software programming can be a fun and very lucrative career. I understand you are lazy but please don't sour kids on it or start them off on the wrong foot.
Also just to add, my tone wasn't meant to be condescending. I just wasn't sure if that was what you were looking for
You just need to claim the course now. Once you have claimed the course, you can start at any time. That's how Udemy works.
Alternative - always free: https://www.udacity.com/course/version-control-with-git--ud123
> or even WHY - really
Recursion is an important paradigm in programming that is needed quite frequently, so it's essential to learn it.
You will need a method that:
reverse
s
for simplicity)
reverse
with the string s
minus the first character plus the first character in s
.It's actually a 4 liner with proper formatting.
Come up with some code from the pseudocode above and then I'll show you a working version in Ideone
Something much more subtle is going on here. They're detecting the User-Agent and adjusting the HTML returned accordingly. If you grab the source with curl then the tracks are filled in correctly (or just use Curl as your User-Agent string). Try the following code. It worked for me just now.
public class Scraper { public static void main(String[] args) throws IOException { String url = "http://www.hiphopearly.com/tracks"; Document doc = Jsoup.connect(url).header("User-Agent", "curl").get(); Elements tracks = doc.select("div.track-listing div.track"); for (Element track : tracks) { System.out.println("Artist: " + track.select("span.artist").text()); System.out.println("Title: " + track.select("span.title").text()); System.out.println(); } } }
You have three threads all making use of the same JointBankAccount object. There is no synchronization within that class; the threads can step on each others toes it's methods are called
I'd recommend having a read of
https://stackoverflow.com/questions/1085709/what-does-synchronized-mean
and doing further reading about thread safety within java
Almost always it refers to the technique of bitmasking, which basically allows you to combine a lot of different information into a single int/long.
An introduction: https://www.topcoder.com/community/data-science/data-science-tutorials/a-bit-of-fun-fun-with-bits/
result of bad benchmark methodology ....
rewrite it using jmh and you will very likely see those difference disappear. If not you could check the generated assembly to see what's up with it.
<strong>What have you tried?</strong>
Giving the solution (even asking for the solution) is explicitly forbidden here.
Use regex101 to develop your regular expressions. This site is easy to use, explains the parameters in detail, and analyzes the final regex.
Hint: You need something like number with length 2, delimiter (as literal), number with length 2, delimiter (as literal), number with length 2.
Note: Java and JavaScript are completely different languages. Codecademy uses JavaScript, not Java.
i=i-1
and i=i--
are certainly not the same thing. There are some interesting things at play here, especially since you are assigning the same variable that you are decrementing. If you take a look at the [MDN site](https://developer.mozilla.org/en/JavaScript/Reference/Operators/Arithmetic_Operators#--_(Decrement\)) they detail the implementation of the postfix decrement operator:
>If used postfix (for example, x--), then it returns the value before decrementing.
So in the statement, the order of operations looks something like this:
i--
returns the current value of i
, such as 10
.i--
then performs the decrement, setting i
to 9
.i = 10
left to evaluate. Obviously, this sets i
back to its original value.But really, just don't decrement and assign to the same variable. If you REALLY want to, use the prefix operator (--i
) as opposed to the postfix one (i--
).
You might want to look at Effective Java 2nd Edition by Joshua Bloch. It discusses a good number of good practises (it was written for Java 6, but those general items tend to not go obsolete). One of those is the toString()
method. While discussing that item, he highlights the following aspects:
toString()
!toString()
implementation makes your class much more pleasant to use.toString()
method should return all of the interesting information contained in the object.toString()
is always public and therefore part of the public interface. Anything that's part of the public interface should never change in behaviour, if possible.)toString()
. (I.e., don't provide any information solely through the toString()
method without making it accessible with its own dedicated method.)If you want to read about good style, you should definitely read Effective Java by Joshua Bloch. It was written when Java 1.6 was the latest version, but it's still the best book on good Java style I've read so far.
I recommend reading Clean Code by Bob Martin, it will help move you in the right direction. The most important thing to keep in mind is each function only having a single job, being as simple as possible.
This might help you out. I can't answer the question as to whether or not it's going to be "fast" enough, since I have no idea what scale you're talking about.
But if speed becomes an issue, then you'll probably want to consider some alternative communication method other than the hacky method of reading a text file as it's being written.
Every class in Java extends the Object class by default. The object class has a toString() method you can override.
In your case it would be something like this:
public class Auto {
//code abbreviated for example @Override public String toString() { return this.PS; } }
And to call the toString method would be something like this:
public static void main(String[] args) {
Auto meinR4 = new Auto("Renault R4");
System.out.println(meinR4);
}
How to use the toString method: https://stackoverflow.com/questions/3615721/how-to-use-the-tostring-method-in-java
More on overriding here: https://docs.oracle.com/javase/tutorial/java/IandI/override.html
It sounds actually like your friend used part of his ram as a RAM disk.
If you look up how to create one, you can use this guide to point idea to it- http://www.sheroz.com/improving-development-performance-moving-intellij-idea-cache-ramdisk
Personally I wouldn't do it with less than 16gb of ram, and even then you might want to check out this article on some drawbacks - http://www.howtogeek.com/171432/ram-disks-explained-what-they-are-and-why-you-probably-shouldnt-use-one/
Plug the code into an IDE - either offline, or online, like IDEONE and test it for yourself.
Add a second loop through the array with System.out.println
statements to print the value of each array entry just before the final }
of the method.
Then call the method from the main
method of your program.
Nothing beats doing it yourself.
In your <strong>last post</strong> you were told to format your code.
You were given even the instructions how to do so, yet, you don't care and still post unformatted stuff.
You were also told to throw your code into a Java IDE, like Ideone and find the answers yourself.
Yet, you post the exact same questions again (minus some), without formatting, the only improvement is that you at least bothered to give the answers that you expect.
Please learn reddit formatting - the instructions are right below the text entry window in the "formatting help link.
Your unformatted posts make it unnecessarily difficult for us to read them and to help you. Further, they give the impression that you don't care for the people who have to spend their time to help you which lends to a feeling that you are disrespectful to the community.
Kindly edit your post to provide proper formatting and follow the rules if you are asking for help.
The more effort you put in your posts, the more inclined people will be to help you.
What you could do to make sure you get the right answers is:
a) read the documentation: For Q1 & Q2: Math.random() which would tell you that the function returns a value from 0.0
inclusive to 1.0
exclusive. Deducting from that, answer a must be the correct one for Q1 because of the given range (20 inclusive, 50 exclusive). Yet, the answers you listed are missing some opening braces (
but I guess that this is more a typo than a trap.
b) Write a little program to test the result empirically, like this (only for question 1)
Both options will boost you knowledge and the second one will even boost your programming skills.
Small trick:
Put the code inside a main class in Ideone and print out the individual tokens.
Nothing beats practice and finding out for yourself.
BTW: What actually is your question?
EDIT: If you have a specific question, it is fine to ask. BUT If the question is about us doing your work for you, or helping you to cheat - don't bother. We will not help you because this sub is not for cheating or doing your work.
https://stackoverflow.com/questions/4704073/how-can-i-get-system-hardware-info-via-java
Using Eclipse doesn't matter at-all. You're writing Java code whereas Eclipse is just an IDE that you write it in.
This is known as 'TwoSum' problem.
Here's an example using HashMap:
https://leetcode.com/problems/two-sum/discuss/141/Very-short-and-simple-Java-code-for-Two-Sum
Depends of if you have a GUI or use the console.
If you for example have an AWT gui see: https://docs.oracle.com/javase/tutorial/uiswing/components/passwordfield.html
If you use a console, see Console.readPassword()
: http://www.tutorialspoint.com/java/io/console_readpassword.htm
Few things wrong here.
(1) You're never actually calling this method
public void setChangePercent(int v1, int v2) { changePercent = Math.abs(((v1 - v2)) / ((v1+v2)/2)*100); }
(2) This wouldn't work anyway, because even if you did call this method, it's taking integer values and returning an integer division when you need to be using floating point division.
Change your setChangePercent
method to use the double
variables you have.
e.g.
public double calculateChangePercent() { double change = previousClosingPrice - currentPrice; double changeInPercent = // rest of calculations. return changeInPercent; }
You seem confused about how parameters work, so I'd recommend you go read up on this
Is your LinkedList
class also custom, or using Java's implementation? When I more or less copied what you have (but didn't inherit from QueueInterface
), I got no errors. If you tried returning list.remove(0)
and it didn't work, then it's likely something that's wrong with either QueueInterface
or your LinkedList
class, assuming it's not the built-in one.
You can practice by doing some problems at:
You will also gain practice by helping others here at /r/Javahelp, at /r/learnJava, or at /r/learnprogramming
Project Euler is a great site to get started on. It's a bunch of math problems (ranging from very simple to needing LOTS of thought) that gives you a goal while programming
You should learn how to use git effectively, but to get you started.
Create a github account and create a new repository. Make sure it's completely empty, no LICENCE or README files or anything.
Install git on you computer
Open the command line and navigate to the folder with your code.
git init
to create you local repository in that folder
git add <files you want to push>
to add files. Then run git status
to make sure all the files you want are added, and none that you don't want.
git commit -m "initial commit (or add any other message you think is appropriate)"
Go back to your github repo in your browser, it should still be empty. Click the green "clone or download button" make sure it is set to HTTPS instead of SSH and copy the url that is there (it should be something like https://github.com/<username>/<name of repo>.git
Back in your terminal, add your github project as a remote repository. git remote add origin <the url you copied from the last step>
(the "origin" part is just a name and could be anything you deem appropriate, "origin" is a common convention though)
Finally, push your code git push origin master
. You will be prompted for your github username and password.
+1 This will work great for many authentication flow needs
I would also suggest looking into OAuth 2.0 as well, below is what caught my eye
> What I'm looking for is simple user creation/registration, 'logging in' to generate temporary API keys and assigning/revoking custom API keys for a user.
Example for JAX-RS (Jersey)
I'd suggest starting with JMonkey, there's tons of documentation and info floating around, and they have a helpful forum too. This would save you the trouble of building your own engine while allowing you to build relatively low level stuff easily(IIRC first tutorial starts you with building a 3d cube and texturing it via code).
We created a chat app for Codename One a while back see this: http://www.codenameone.com/blog/building-a-chat-app-with-codename-one-part-1.html
The networking portion used pubnub which made things really trivial and its available for all modern OS's so you should be able to use it anywhere without much of a server.
I believe the task is to iterate over the keyset, and count the size of the list in the values.
List<Position> list = new LinkedList<>(); list.add(foo1); list.add(foo2); map.put("foo", list); list = new LinkedList<>(); list.add(bar1); map.add("bar", list);
System.out.println(most());
This would then print out "bar" because the size of the associated list is 1 (compare with the list of size 2 that is at "foo").
Aside, you're probably supposed to use keySet()
, and get(key)
. If you're not, glance at entrySet() (javadoc.
for (Entry<String, List<Position>> entry : map.entrySet()) {
This then gives you access to entry.getValue()
which returns the value with the associated key (accessible at entry.getKey()). Not an issue for academic work, but if you're dealing with large maps where you are going to be doing a 'get()' for each and every key in the map, the entrySet is more efficient. Findbugs has a warning about it:
> "Inefficient use of keySet iterator instead of entrySet iterator This method accesses the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup."
You need to tell javac where to look for compiled classes:
javac -classpath classes -d classes src/rps/Strategy.java
This is why it's usually better to use an IDE, or if that's not allowed, a build system such as Ant.
Also, in looking at the other classes you uploaded, the packaging appears incorrect. You have classes in the strategy directory, but the package in the code is rps. This will not compile.
Launch4j if it's a desktop app.
There are a few different products like this, but L4J is free and works well enough. You can wrap your app and resources in an executable container, along with the JRE if you like.
My experiences with Launch4j have been very good, e.g. you can (manually) put a copy of your installed JRE (leaving of JavaFX, if you don't need it, saves 30 MB or so) in a subfolder of the tree you want to distribute and insist that this JRE will be used for running. All the user would have to do is to unpack the tree (which in turn you could let an installer or an executable archive do), no JRE-installation required.
That's just one of a lot of features, though an important one. Took me like half an hour with no prior l4j experience to make this work.
The jar will optionally be inside the exe instead of separate, and it will not be unpacked for running.
Try codingbat if you have not already. They have both java and python problems.
Next I reccommend trying the 8-queens problem for java and then afterwards try to develop simple games like pong, brick breaker, etc. If you need help or guidance with any of those PM me but those are all very good options. I also like to play with Graphics2D a lot.
Tinder doesn't have an API as far as I know (probably for the better since it would be really easy to abuse) -- so you'll have to automate the app itself.
People have already posted about services you can use for facial recognition and chat.
As for actually controlling the tinder app via code, you'll have to use a framework that let's you automate the app like Appium or Robotium and run the Tinder app on a spare physical device, or the Android simulator, or even rent out a device in the cloud on something like AWS Device Farm or BrowserStack's App Automate.
Good luck!
Try using VisualVM to see what's happening during GC. You want to see a stable sawtooth pattern on the heap graph. If the teeth keep going up then you've likely got a memory leak.
No love for swagger?
It's different than Enunciate, you define your api in a standardized way, then it handles it from there...
EDIT: What is swagger?
This is the output I get when I run you program (I used 299 for x and 520 for y, arbitrary). I get other than 0 for closestX, closestY. I think you are going to have to show me more (all) code in order to help more.
That's actually a fairly difficult question to answer. The first step is understanding what you are actually trying to prevent. SQL injection? Denial of service attacks? Privilege escalation (in the sense of changing data that the caller shouldn't be able to? Once you have an idea of what you're trying to address, then you can look at your code and figure out how *you* (having a far greater understanding of any vulnerabilities than an outside attacker) would try and manipulate your system.
Since you mentioned already having a CI pipeline in place, you might consider something like SonarQube. It is an open source static code analyzer that looks for common problems in both coding style, (and to an admittedly lesser degree) obvious security issues. In fact there are several products that range from this sort of SCA to apps that will actively perform penetration scans.
If you can give us an example of what sort of service you'd be interested in securing, we might have better answers. The tech stack you're using would help a lot. Are you writing to a database and you're concerned about people changing data? Reading sensitive information you want to limit access to?
The way you phrased that question reminds me of a lot of IA people I've worked with. Someone has said "go make it secure!", but without actually trying to define the problem space or what you are trying to prevent.
Concrete examples can go a long way towards making sure we're all talking about the same concepts.
One difference I have not seen mentioned yet is that GC gives the JVM freedom to decide when to collect garbage. It can make various throughput vs. latency tradeoffs with different implementations since it is not forced to free memory based on an instruction in your code. It also has the freedom to make decisions based on information that is only available at runtime such as whether to allocate on the stack, from a TLAB, or from shared heap memory.
There are a number of different collector implementations and each is tuned based on different workloads. Some applications can tolerate latency spikes better than others, and this can allow the JVM to collect with higher throughput if it is able to "stop the world" for as long as it feels like.
Recently, there has been more focus on adding lower-pause collection algorithms like Shenandoah since there has probably been a big rise in applications that are sensitive to these pause times (many distributed systems detect failure based with some kind of heartbeat mechanism).
That being said, there are some RAII-like patterns in Java with the introduction of AutoCloseable
and try-with-resources
blocks. This is because resource management is not handled by the garbage collector. You still have to think of lifetime and ownership when your objects represent resources.
try (Resource r = new Resource()) { // resource is only alive within this scope } // it might not have been GC'd yet here, but the resource has been freed!
This kind of thing will be much easier in Java 1.9 as its new module system supports muti-release jars which appears to be what you need:
http://openjdk.java.net/jeps/238
Meanwhile, +1 to /u/tadaskay's link.
Typically you only require an OOP approach for larger problems. Those sites are typically suited for a wide range of languages, some which may not be OO.
I learned OOP by making little side projects. I think my first project was TicTacToe or something, and moved on to Space Invaders and whatnot (games are generally more fun to program, but that depends on you).
Maybe try hacker rank and see if that helps you.
E: Just tried a few problems at hackerrank, they are crappy "fill in the blanks" types of questions that really won't teach you anything. Try making a simple project.
Hi!
There are multiple ways that you can do this. The quickest/simplest way to handle this kind of requirement is to use a HashMap. A Java HashMap is essentially a hash table with keys and values. In your case, the key would be the STATE and the value would be a LIST of teams originating from that state. For example...
[MI] --> {TEAM A, TEAM B, ...}
Now, your job is to populate the HashMap with the appropriate Keys and Values. Here is a good example on HOW to use the HashMap in Java.
Once the HashMap is ready, you can then iterate through it and print out the appropriate/necessary values!
You'll want to use PreparedStatement if any of the parameters are user-facing (or ever will be), to protect against SQL injection attacks.
This tutorial shows the important parts.
OK, so you have:
while (true) { accept a connection; create a thread to deal with the client; }
which is a good start.
So it looks like you're trying to create the server side of a server-client pair.
Here's an example to save me writing it out:
OP, your teacher wants you to make getters and setters for myCard variable in a PlayingCard class. You can read all about it here
> no standard format for author name or any of that stuff
Yes there is, javadoc. You don't have to use it of course but it's the standard and highly useful
Use a tester like this. Note that you don't need to escape the backslashes (e.g. use \b instead of \\b).
Because you want to separate on more than whitespace, you're going to have to change the \b to [^A-Za-z]+ -- at least one non-letter -- or word boundary, and then use a capture group to on the actual pattern you want to match.
Another (probably better) strategy would be to replace non-letters up front with spaces -- since you don't care about them anyway -- and then use the a regex with a word boundary to parse them.
> We were thinking about using a .txt file,
Simple, but mostly sufficient approach.
> but I can't find any useful help whatsoever.
Can you be a bit more precise what exactly you are looking for?
Is it file reading/writing? -> Check out Writing and Appending Data to a Text File from /r/javaexamples
You could think about using Markdown Syntax to format your text file.
If you need multiple notes, you could also think about XML formatting.
Post all of your code on http://gist.github.com. It looks like the error is somewhere else and the compiler gets confused.
Also: if you want help with issues please don't paste screenshots of compiler errors like that. Compile the code on teh command line (with javac) and post the entire error log.
If think SQlite is suitable for this situation.
What you'll have to do is to create a table based database with sqlite. Each user will have its own row in the table with the data you wish to save. Then later you can access this table by for example to user name and retrieve the information.
A table example would look like that: When ID is the primary key, and the progress is represented by an INT as for a stage. (Just an example ofc)
INT ID STRING NAME INT PROGRESS
1 John Snow 2
2 Patrick Star 6
3 Jack Rabbit 3
This is doable but best done in steps. Feel free to ask plenty of follow-ups.
bin/
directory to start/stop Tomcat.webapp/
directory. By default, the context root of the webapp (i.e. example.com/mywebapp) will match the war file name minus .war
.If the webapp is depending on a preconfigured JNDI DataSource (you can ask the devs if it does) then we can go through configuring that. If the webapp instead is using some known username/password/schema combo to create a DataSource then you might not need to do anything assuming the role is already in PostgreSQL.
In short: Eclipse & IntelliJ have it both built in. (Don't know about Netbeans, though, because I am not using it.)
You'd want to highlight the component and use <code>Ctrl+O</code>, then add an <code>ActionListener</code>. This listener will be fired upon the button being triggered (mouse, enter, hotkey, etc).
This, as well as the checking values of other components, will need to be done through code. No GUI designer is that good to determine all of this.
On a side note, I always recommend people to learn how to program GUIs manually. It makes for a lot better learning experience and makes debugging a lot easier.
Especially for a beginner, I would rather recommend https://www.jetbrains.com/idea/download/
It keeps much closer track of your code, tells you what is probably wrong, makes suggestions on how to improve it, has a lot of comfortable refactoring features - e.g. you can just invert the direction of an indexed for loop without a second thought, or you can convert it to (and from) an advanced for loop etc.
I can't recommend this IDE enough, as long as you don't need Eclipse-specific plugins or work in an environment where others use a different IDE. You can easily switch back and forth between Eclipse and IntelliJ IDEA at any time on an ongoing project, though. Cave-at: I have no idea if the default syntax highlighting colors suck. The first thing I did was to thoroughly redesign them for my needs, I have no memory of how it once was.
I'm legally using the free Community Edition for commercial code.
Yes, this is entirely possible.
You will probably need a HTML Parser library like JSoup and/or a browser automation tool, like Selenium Webdriver.
Both libraries are very well documented.
Do OCPJP8 to round off your Java knowledge. It has Generics and Threading which OCA does not cover.
Read Clean code (Robert Martin), Refactoring (Martin Fowler) and Head First Design Patterns to improve software design.
Further on study some frameworks such as Spring, Hibernate, Web Services and maybe JUnit depending on what's required for your job.
> I have already done the for loop doing charAt(x) and auto boxing it for a matchs("1") to get the Boolean. Would like to not do that due to the number of times I will need to parse it cause JSON.
Some quotes from Effective Java (2nd Edition):
>More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason—including blind stupidity.
—William A. Wulf [Wulf72]
> We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
—Donald E. Knuth [Knuth74]
> We follow two rules in the matter of optimization:
>Rule 1. Don’t do it.
>Rule 2 (for experts only). Don’t do it yet—that is, not until you have a perfectly clear and unoptimized solution.
—M. A. Jackson [Jackson75]
So, if what you have works and it's not a bottle neck, there is no need to make the code more convoluted just for "performance" reasons.
As others said:
"core java" usually means to understand the core language like java syntax and control structures, collections, threads, byte streams, common design patterns and so on in contrast to stuff like osgi, spring, rxjava, android or other larger libraries/frameworks.
Books like "Effective Java" by Bloch handle core java stuff.
That is a 500-line class that's doing a lot of stuff. That violates the Single Responsibility Principle, which is one of five principles in S.O.L.I.D. Break that class up into classes that have a single responsibility. Then write unit tests with your test library of choice. So, your tasks are to break up big classes and write tests. To help you, read "Clean Code", by Robert C. Martin.
There really too many Java specific things that I'd recommend. Pretty much all of the language agnostic stuff applies across the board.
Learn the basics of Git, SVN, or some other VCS
Understand the basics of time complexity of common data structures and algorithms. Not because you'll be mulling these over for hours on end, but so you'll intuitively avoid writing code that won't scale
Know the ins and outs of polymorphism, inheritance, and object composition. For example, if you're building a form where a customer fills out order data, you can have an identifying info object, address object, payment object, shopping cart object, etc. Then use those objects to make an application object, i.e. composition. If you have different types of objects, make a common application object, then subclass it with your specialized application objects. Clean Code goes over this very well.
Documentation. People skimp over this because it seems like a no brainer. Writing clear and concise documentation is a lost art. People (in my experience) tend to write so little that you may as well leave it blank or get so in depth that you could have code golf'd the function.
Don't catch <code>Exception</code>; catch what's necessary and handle it properly. There are a bunch of anti-patterns that are easy to fall prey to.
Get yourself a copy of the following books and read them:
"Effective Java", by Joshua Bloch
"Clean Code", by Robert C. Martin
Find open-source Java projects on GitHub that you like and contribute. Find bugs, write fixes, create pull requests, etc.
Head on over to /r/AndroidDev and lurk, read, and ask.
The search function of this website is a great place to start.
http://mooc.fi/courses/2013/programming-part-1/
Head First Java
Effective Java - 2nd ed.
Java - A beginner's guide 6th edition
It honestly depends on you, whether you feel more comfortable watching tutorials or reading through books. I have personally not read the book you referred to, however I can recommend another book that I feel is quite good "Head First Java"... Anyways I feel on either approach it is not enough to watch the video or read the book, it is much better to try a project on your own, facing problems and finding answers, that is the best way to learn in my opinion.
Reading the book "Effective Java" is a good start on this topic, spesifically regarding garbage-collection, and boxing / autoboxing.
An example would be sticking to primitives, avoiding boxing when not needed, and generally finding more efficient ways to solve tasks.
Get a book called Head First Java. Java can be quite intimidating when you first start learning it and that book does a fantastic job of demystifying it and making the language fun again, so it's perfect for people such as yourself who don't get on with the formal style most Java is taught in. Plus, it has the best explanation of Object Oriented Programming I have seen anywhere.
Huh, that would be real frustrating to sit through a java class which uses powerpoint slides. Hands on is the way to go.
I taught myself java from the complete reference book. Once I picked up the basics I went through the "Thinking in java" book, and worked through their exercises. At intermediate level, you can pick up Effective Java by Joshua Bloch. Eventually you may want to look into Lambdas/Functional programming features introduced in Java 8. I used some online tutorials to wrap my head around this (still learning). HTH.
The Oracle tutorials are pretty helpful.
https://docs.oracle.com/javase/tutorial/
Effective Java is a good book, it offers best practices. I'd recommend becoming more familiar with the language first before you read it.
> Effective Java (2nd edition).
Effective Java is an excellent book, but it doesn't teach you Java. It takes you from from intermediate to advanced Java, but it's not for starting.
Once you've learned the basics, I'd absolutely recommend reading it.
I've read both Effective Java and Clean Code and highly recommend them as well.
There's also Agile Software Development (by Robert C. Martin): http://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445/ref=sr_1_1?ie=UTF8&qid=1451828712&sr=8-1&keywords=agile+software+development
This book contains among other things a description of the SOLID principles of software design. For example the Single Responsibility Principle tells you that each class should have only one responsibility. This reduces coupling and leads to small and more easily understandable classes. The book also contains some nice case studies showing how to apply these techniques.
While Clean Code deals with writing code and how to design methods and classes, Agile Software Development tackles the topic at a higher level and discusses how to develop and design software consisting of different classes and packages etc. It requires a basic knowledge of programming and OO, though.
Robert C. Martin has also created a series of purchasable training videos at cleancoders.com. These videos cover the topics of both books starting with the rules for clean code and then going into the SOLID principles and other advanced topics.
Head First Java contains a "simple chat client" and server in chapter 15, sources are available here: http://www.headfirstlabs.com/books/hfjava/
Note concerning the chat server: "Every possible disclaimer ever disclaimed is in effect here. To keep the code stripped down to the bare essentials, we took out a lot of parts that you’d need to make this a real server. In other words, it works, but there are at least a hundred ways to break it."
Effective Java by Joschua Bloch. It's probably too advanced, but as far as I know it's the only "must read" Java book. The one downside is that it was written for Java 6, but most of the content is quite "timeless" and will continue to be good advice for a few more years.
> This is a bad sign, since it means, in your Sprite class, you have a line like public static Sprite playerUp;
Not necessarily. Sprite could be an enum, which would then be perfectly valid code. In fact, sprite types probably should be enums. From Effective Java:
> So when you should you use enums? Anytime you need a fixed set of constants. ... includes planets.. days of the week... chess pieces... choices on a menu ... operation codes.
A fixed list of sprite types is a good choice for an enum.
Get a GitHub account (free). Write lots of little Java programs to do interesting things and use GitHub to host the repositories. You must practice what you learn as you learn it or else you'll fail to retain it. Here are some programming challenges to get you started.
Read other people's code. Again, GitHub is a useful place to find it.
Read Effective Java (Bloch).
Lol ik there's plenty already available. But I'm learning Java rn; this is good practice. It's like coding SHA-1 on Scratch (my project lol) -- there's no point but it's a good exercise.
You could always try it. The random access part should work pretty much as you think it is, but I'm not 100% certain whether or not RandomAccessFile is going to try and load the whole thing into memory first. You'll find out quickly enough if you suddenly have a lag spike and 5GB extra used memory. From what I can read on the internet, it shouldn't though (but for some reason the term blocking comes up in this context and I'm don't know what that's referring to).
The other solution I know of uses all the data in a single file anyways, and that's using MappedByteBuffer which will let the JRE figure out what needs to be in memory or on disk.
You could always try implementing both and seeing which is better for what you're doing. Since they both can use the same input file it shouldn't be too much extra work.
Here's a stack overflow post that covers a bit of both of these. The bottom comment also brings up AsynchronousFileChannel for faster writes.
--
Keep in mind the difference between storing it as raw data vs characters though. It's easy to forget when you're not thinking about it.
My personal approach for these things - it's not the combo box that you want to be dynamic - you'll only need to "new" the combo boxes themselves once,
What works for me is manipulating the model that provides the data to the combo boxes.
Create yourself a little test app where you "new" a combo box model, then "new" a combo box using that model and add it to some frame/panel. Put another button on the panel and make it so the click of the button changes something inside that model you created (e.g. it adds an entry).
You could also just replace the model behind a combo box entirely:
https://stackoverflow.com/questions/4620295/dynamically-change-jcombobox