I need a little java help.
So I'm in a Java class and it's only been a couple weeks, so I'm pretty new to this.
The assignment is to create a program that will take user input of a website from a JOptionPane and return whether it's a government, commercial, or educational website.
I tried using String methods, but I can't seem to get my code to isolate the last 3 characters of a string of variable length, even tried doing an indexOf and couldn't get it to display the following characters.
I just need tips, hints, or advice, I don't want you to do it for me.
Thanks guys.
Edit- NVMND I figured it out, I only needed one int in substring which was the '.' from my indexOf, it then stores the rest of the string following that as a new string, but please, if you know of an alternate way to do this please feel free to share.
If you look at the API documentation for the String class
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html
You will see there is an "endsWith" method, which only works if the three letter identifier is the last thing in the URL.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now