Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #9120

Re: Question regarding methods and classes

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Question regarding methods and classes
Date Sun, 23 Oct 2011 08:54:01 -0700 (PDT)
Organization http://groups.google.com
Lines 68
Message-ID <22389553.296.1319385241947.JavaMail.geo-discussion-forums@yqnv12> (permalink)
References <4ea389df$0$13444$9a566e8b@news.aliant.net> <j807nt$8h6$1@dont-email.me> <j807ru$8h6$2@dont-email.me> <4ea4177e$0$19700$9a566e8b@news.aliant.net>
Reply-To comp.lang.java.programmer@googlegroups.com
NNTP-Posting-Host 72.14.225.65
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1319385245 418 127.0.0.1 (23 Oct 2011 15:54:05 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Sun, 23 Oct 2011 15:54:05 +0000 (UTC)
In-Reply-To <4ea4177e$0$19700$9a566e8b@news.aliant.net>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=72.14.225.65; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9120

Show key headers only | View raw


Linus Flustillbe wrote:
> So that works really well.
> 
> package helperClasses;

By widespread but not quite universal convention, package names should be all lower case.

> public class rType {

By universal convention, class names should begin with an upper-case letter.
<http://www.oracle.com/technetwork/java/codeconv-138413.html>

>    public static boolean isBetween(int a, int b, int c)
>    {
> 	return (a <= c && a >=b);

PLEASE DO NOT INDENT USENET CODE POSTS WITH TABS!

>    }
>    public static boolean isBetween(double target, double lower, double upper)

Why did you switch to intelligent variable names here, but not in the other method?

>    {
> 	return (target <= upper && target >= lower);	

PLEASE DO NOT INDENT USENET CODE POSTS WITH TABS!
	
>    }
> 
> }
> 
> import static helperClasses.rType.*;
> class rTypeTest {

By universal convention, class names should start with an upper-case letter.

>   public static void main(String[] args) {
>      boolean hello = isBetween(4,6,87);
>      System.out.println(hello);
>      boolean hello2 = isBetween(5.4, 2.3, 9.2);
>      System.out.println(hello2);
>    }
> }
> 
>  
> false
> true
> 
> I understand the concept of overloading methods... I haven't done much
> Java in few years so I'm taking a refresher by going through the Java
> Tutorial.  What does adding the "static" modifier to the import
> statement do?  Since the methods in the rType class are already defined

Read the manual.
GIYF.
<http://lmgtfy.com/?q=Java+import+static>

> as being static (only one instance no matter how many times the class is
> instantiated ... see I read up on that)  why do we need the modifier 
> except to make the code compile?  Or is that the only reason.. because
> Java needs it? 

The "import static" directive lets you import static (get it?) members from another class.  This obviates having to prefix those members with the class and the dot operator.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Question regarding methods and classes Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-23 03:28 +0000
  Re: Question regarding methods and classes Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-10-22 20:44 -0700
    Re: Question regarding methods and classes Patricia Shanahan <pats@acm.org> - 2011-10-23 06:14 +0100
  Re: Question regarding methods and classes markspace <-@.> - 2011-10-22 22:12 -0700
    Re: Question regarding methods and classes markspace <-@.> - 2011-10-22 22:14 -0700
      Re: Question regarding methods and classes Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-23 13:32 +0000
        Re: Question regarding methods and classes markspace <-@.> - 2011-10-23 07:43 -0700
        Re: Question regarding methods and classes Lew <lewbloch@gmail.com> - 2011-10-23 08:54 -0700
  Re: Question regarding methods and classes Roedy Green <see_website@mindprod.com.invalid> - 2011-10-23 01:37 -0700
    Re: Question regarding methods and classes Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-23 13:49 +0000
      Re: Question regarding methods and classes Roedy Green <see_website@mindprod.com.invalid> - 2011-11-02 01:23 -0700
  Re: Question regarding methods and classes Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-23 09:11 +0000

csiph-web