Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Keeping loops straight & Learning in a more efficient way

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm familiar with the concept of loops as far as nesting and such, my question is: How do keep all of it straight in your head?

I'm sitting here deciphering these things over and over again for school, so these are things i've had no hand in coding, and honestly beyond a certain point my brain just throws it's hands up because it can't keep the whole routine going without dropping some other portion of it.

do you write it out on paper? is there some standard method for doing this?

a simple loop is easy enough, but once you get 3-4 factors cycling, incrementing by different amounts and updating each other, it seems impossible to do mentally, at least to me.

While i have you, I'm having a hard time differentiating variables from built in java methods when i'm shown examples. Many times i'll see a chart, lately it was "isDigit()" it didn't have anything that said it needed "Character." in front of it there.
later on in a code example it was shown as Character.isDigit(); I have no idea if character is referring to some method they set up elsewhere, having to do with some variable, or is intrinsic to the command. I don't know what to ignore or assume as this is how i'm learning java.
I bought two books on Java and went searching for isDigit and found nothing discussing it beyond what that chart had, one of them didn't have it at all. Surely there is a more straightforward way of learning this stuff. I have a teacher, but he typically takes about
a day to get back to me, and the amount of work i have for his class doesn't afford me that luxury.

Sorry for the novel. i'm just frustrated, i feel stuck, and zybooks isn't the best teacher.
 
Master Rancher
Posts: 4176
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

built in java methods  


You can find what methods are declared in what Java SE classes by opening the API doc page:  https://docs.oracle.com/javase/8/docs/api/index.html
At the top of the page is a blue banner with links.  Click on the  INDEX link.  That takes you to pages with lists of methods.  In the list of letters: A B ... Z click on the first letter of the method you are interested in to get a page with all the methods starting with that letter.  Then scroll down or do a Find for the exact method you are interested in.
 
Justin thee Turner
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for the resource, but :


{public static boolean isDigit(char ch)
Determines if the specified character is a digit.
A character is a digit if its general category type, provided by Character.getType(ch), is DECIMAL_DIGIT_NUMBER.

Some Unicode character ranges that contain digits:

'\u0030' through '\u0039', ISO-LATIN-1 digits ('0' through '9')
'\u0660' through '\u0669', Arabic-Indic digits
'\u06F0' through '\u06F9', Extended Arabic-Indic digits
'\u0966' through '\u096F', Devanagari digits
'\uFF10' through '\uFF19', Fullwidth digits
Many other character ranges contain digits as well.}



means very little to me. at no point does it show Character.isDigit(); in an example with say, a string. It just shows (public static boolean isDigit(char ch)) . it definitely shows Character.getType(); which is more confusing than when i got there seeing as i was trying to learn about the previous command and see an example of it's implementation.
That's to say i even know that it's a class built into Java in the first place. Is there a better resource for learning Java, or am I just not cut out for it? I feel like most things i try and access leave out things when they explain them, and code must be exact, therefore my code will never work
without exact explanations.
I feel like i have to scour the net and wade through 3-4 videos just to pars a simple 2 sentence explanation of a basic concept. Maybe i'm just burnt. Just seems like a terrible way to learn java.
 
Norm Radder
Master Rancher
Posts: 4176
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

show Character.isDigit(); in an example with say, a string


The API doc you posted shows that the argument passed to the isDigit method must be char.  The arguments are in () following the method name.


a better resource for learning Java


The API doc I posted a link to is  not a place to learn how to program.  It is a reference for those that know how to program but need the correct method name or syntax.
Another reference is the java tutorials:  http://docs.oracle.com/javase/tutorial/reallybigindex.html gives a list of topics that can be studied.

I do not have any resources For an absolute beginner to learn programming.  Hopefully some others on this forum can provide that.
 
Bartender
Posts: 7730
70
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to determine if a String is an int you have to write your own.
 
Justin thee Turner
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think i may have worded my question poorly.
The particular exercise required me to use isDigit() with a string and use it's locations as the character. I (sort of/maybe) know how to use it now. I used it as an example of something that was taught in an incomplete way
and caused me to get behind in my work from having to scour the net for answers to something that could have been explained in about a sentence or two.

Do you know of a good resource for me to learn with so this doesn't keep happening?

I bought "head first java" which didn't even return a result for isDigit when i searched it. I also have "Murach's beginning Java" which is a better text, but had the same problem of it just glossing over it.


 
Norm Radder
Master Rancher
Posts: 4176
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

exercise required me to use isDigit() with a string


Since isDigit takes a char as its argument, you need to get the char values that make up the contents of the String.  There are several ways to do that:
one by one with a  get method that takes an index value to select what char you want
or extract all the chars in the String to an array that can be iterated on.
 
Marshal
Posts: 72036
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say that you need to read the API as much as possible and only take notice of the parts you can actually understand The other parts will make more sense as you become more experienced. Or if you ask somebody else more experienced for explanations. There is a lot to learn and a lot not to learn and it will become clearer with practice.
Unicode is a system for putting numbers to symbols from all sorts of different languages; the numbers after the \u are the values recorded (in hexadecimal) and what follows is the name Unicode applies to those ranges. For example, \u0660 = ٠ which is Indo‑Arabic for 0.

Carey Brown wrote:If you want to determine if a String is an int you have to write your own. . . .

The nearest I know using a standard API method is,Because the first “token” in that text is convertible to an int, that code will print true.

BTW: JTT, have you come across JShell. It should be installed along wit which is Indo‑ for 0.h Java┬« and you call it from the command/terminal with jshell. You can copy'n'paste that code into J#Shell and see it executed directly.
And . . . welcome to the Ranch();
 
I am a man of mystery. Mostly because of this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic