A print() method in class Object will make things a lot simple

  • Thread starter =?iso-8859-1?B?bW9vcJk=?=
  • Start date
?

=?iso-8859-1?B?bW9vcJk=?=

Hi,
It can not measure how many lines of System.out.println() has been used
around the Java world. I think if there is a function like this:

public static void print(String msg){
System.out.println(msg);
}

Inside class Object will make many developers' lives a lot of simpler,
do u think so?
 
B

BartCr

If you really want this, it is not so hard to add (since 1.5):

package print;

public class Printer {
public static void println(String msg) {
System.out.println(msg);
}

public static void print(String msg) {
System.out.print(msg);
}
}

Use:

import static quick.Printer.*;

public class Test {

public static void main(String[] args) {
println("test");
}
}

There, all you want without waiting for a new Java release :)

Grtz,

Bart
 
M

Monique Y. Mudama

Hi,
It can not measure how many lines of System.out.println() has been used
around the Java world. I think if there is a function like this:

public static void print(String msg){
System.out.println(msg);
}

Inside class Object will make many developers' lives a lot of simpler,
do u think so?

I can't see the point of this. Could you show an example where this
would be useful?
 
?

=?iso-8859-1?B?bW9vcJk=?=

well, I spent a lot of typing for using System.out.println, dont you?
 
S

Stefan Ram

Roedy Green said:
You can program the keyboard with macros so it will type
strings from shorthand.

Here are some of my macros for the Windows program "AllChars":

jvm=public static void main( final java.lang.String[] args )
jsp=java.lang.System.out.println(
jsd=java.lang.System.out.println( "o =( " + o.getClass().getName() + " )" + o );

My macro key is "q", so when I type "qjvm" it is replaced
by "public static void main( final java.lang.String[] args )".

A real macro processor could even parameterize code, which
would be helpful in the case of the last macro above, where
the user still needs to replace "o" by an actual reference
name to be written.

For example, here are variants of common keywords, which are
intended for reference expressions instead of boolean
expressions and which are defined using a preprocessor.

$define IF if(( $1 )!= null )
$define WHILE while(( $1 )!= null )
$define UNLESS if(( $1 )== null )
$define ASSERT assert(( $1 )!= null )
 
M

Monique Y. Mudama

well, I spent a lot of typing for using System.out.println, dont
you?

I would really appreciate it if you quoted the text to which you're
responding.

Anyway, no. Adding a "println" method to Object would save you 10
characters (not "print" because that implies no newline). Big whoop.

If you really want to save some characters, I suppose you could do the
following (which, from a code readability standpoint, I strongly
discourage):

iimport java.io.PrintStream;


public class SystemOutTest
{

static PrintStream p = System.out;

public static void main (String[] args)
{
p.println ("Look ma, fewer keystrokes!");
}
}
 
L

Luc The Perverse

Monique Y. Mudama said:
I would really appreciate it if you quoted the text to which you're
responding.

Lately there has been a huge increase in the number of people refusing to
quote text while replying
 
M

Monique Y. Mudama

Get a newsreader. They are free. It saves having the irrelevant
stuff endlessly requoted. If you lose track of context it is just a
keystroke away.

http://mindprod.com/jgloss/newsreader.html

BS.

Conscientious quoting (that is, snipping the irrelevant bits and
including the parts to which you're actually responding) is part of
being a good netizen. I don't want to have to reread a 500 line post
just to guess at which part someone found interesting.
 
T

Thomas Weidenfeller

Roedy said:
Get a newsreader. They are free. It saves having the irrelevant stuff
endlessly requoted. If you lose track of context it is just a
keystroke away.

Newsreader or not, it is a courtesy to quote the parts you are replying to.

/Thomas
 
B

blmblm

Get a newsreader. They are free. It saves having the irrelevant stuff
endlessly requoted. If you lose track of context it is just a
keystroke away.

http://mindprod.com/jgloss/newsreader.html

Two points:

(1) Irrelevant stuff is not supposed to be requoted, only the points
to which one is replying.

(2) I wonder about that "just a keystroke away". I use trn, and I
have it configured to retrieve articles from the news server one
at a time (rather than maintaining a local cache of articles),
so trying to search back through a thread for the replied-to
article .... Actually there *is* a keystroke command to do that,
but it requires another fetch from the server, and often simply
doesn't work. Could be a problem with how I have it configured,
could be simply a bug, who knows. Best case, though, is "only a
keystroke, and a wait while the article is fetched from the server".
Do other newsreaders behave "better" in this regard?
 
R

Roedy Green

Newsreader or not, it is a courtesy to quote the parts you are replying to.

But you have no control over what other people do. As you can see, all
the screaming about top posting, multi-posting, too much quoting, too
little quoting, trolling and spamming has not managed to come anywhere
near controlling others.

So your best defense is to get a newsreader which helps you deal with
the crap.
 
R

Roedy Green

I wonder about that "just a keystroke away". I use trn,

That is not what I mean by a newsreader. A newsreader maintains a
local copy of posts you have already read in the last week or so.
 
B

blmblm

That is not what I mean by a newsreader. A newsreader maintains a
local copy of posts you have already read in the last week or so.

Oh good, a newsreader snob. I'd have just said that it was a
special-purpose program for reading Usenet news, as opposed to
using one's browser or e-mail program ....

Something that actually sounds like its meets my criteria as well
(runs nicely from the command line in text mode and lets me use my
text editor of choice) is pine, which is a mail client .... no,
"Program for Internet News and Email". Hm! I didn't know that.

(Deep sigh as blmblm contemplates installing and configuring yet
another piece of software, and trying to make its keystrokes reflex
actions .... )

It still seems a bit wasteful to maintain a local copy of all posts
read, even the junk, but maybe disk space is so cheap these days
that no one cares.

The other option, of training newbies in the customs of the "place"
in which they find themselves, is probably no longer an option, alas.
 
B

blmblm


You will notice from my other post that I had already decided that
maybe I should read *all* of the above page before posting a snide
reply. Previously I read only far enough to confirm my prejudices,
and skipped your list, incorrectly assuming that there would be
nothing of interest for a text-mode fanatic. pine, hm ....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top