Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Emp75

Members
  • Joined

  • Last visited

Everything posted by Emp75

  1. Well, that would be your problem. Try replacing the line: private static String[] elements; With this : private static String[] elements = {"Honesty","Kindness","Laughter","Generosity","Loyalty","Magic"}; //Remember to initialize this array to something before trying to access it. Princess Luna is the best Pony. Honestly do not use this code in the final version of this program, from wyvren2000 The array is 103 inputs and they are supposed to be read from a file that I have. The file is an excel chart with every element in the periodic table that looks like this: | Name | Atomic Number | Atomic Weight | Symbol | 1| | | | | 2| | | | | 3| | | | | 4| | | | | etc. all the way down to 103. I have another question (yeah, I'm pretty bad at this) I am trying to set up a method that is used like this: mol.displayAtomicMakeUp(); I have initialized mol in the main and I'm trying to get the displayAtomicMakeUp() method to read in what mol actually is. It might sound a bit strange, but I'm not sure how to word it. If it was displayAtomicMakeUp(mol) it would make more sense to me, as I know how to actually take what mol (a string) is from that but what do I do for mol.displayAtomicMakeUp()?
  2. Just using that class, I'll see if I can get the isDigit method working.
  3. We haven't learned what the isDigit method is, could you perhaps go into more detail as to how to use it? Well all I'm trying to do is create the Periodic Table data type which is just an array of all of the elements in the periodic table. The elements are stored on excel with the name, atomic number, atomic weight, symbol. In the constructor I'm just trying to read in the file and enter the data into the array and the display method to just print out the information in the array. The first 6 in the array would look like this. Hydrogen,1,H,1.01 Helium,2,He,4 Lithium,3,Li,6.94 Beryllium,4,Be,9.01 Boron,5,B,10.81 Carbon,6,C,12.01
  4. I'm working on a program assignment for my Introduction to Java class and I need help a few things. Is there anyway to split a String by characters and numbers? For example, the assignment has to do with molecular formulas and for Prozac the formula is C17.H19.F3.N10 I have split the formula by each of their atoms and how many of them using Stringtokenizer but I want to split each token (C17 H19 F3 N10) by their atoms and how many of them, so right now I have the string "C17" and I want to split that so I have atom = C and number = 17 For this example each atom is only one letter but others might have an atom with more than one letter so I can't just use substring. I also have to create a PeriodicTable data type and I'm getting the NullPointerException and I am unsure as to why. Here's my code: import java.util.*; import java.io.*; public class PeriodicTable { private static String[] elements; public PeriodicTable() throws IOException { elements = new String[103]; Scanner filein = new Scanner(new File("elements.csv")); int k=0; while(filein.hasNextLine()) { elements[k] = filein.nextLine(); k++; } } public static void display(String[] ar) { for(String item: ar) { System.out.println(item); } } public static void main(String[] args) { display(elements); } } Any advice would be appreciated.

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.